[Csnd] Cs for Android - problem with "intelligent" pitch shifter
Date | 2018-09-13 14:56 |
From | 00000008a49663bc-dmarc-request@LISTSERV.HEANET.IE |
Subject | [Csnd] Cs for Android - problem with "intelligent" pitch shifter |
Dear list, I'm creating a multieffect processor for Csound For Android, here is the github link https://github.com/triceratupuz/matrix-processor I've added an intelligent pitch shifter (harmonizer) as instr 155 of the file mat_proc_tpz.csd, the problem is that the produced notes are not harmonized correctly, I've copied the same code in a dedicated csd (see file harmonizerTest_minus.csd in the tests folder) and it works correctly. I don't understand why the same code produces wrong result in one case since the difference is basically that instead of reading/writing directly audio with inch/outs it reads and write audio in arrays; the parameters k variables (named kpar1, kpar2, kpar3) seems to receive/produce the same values. Any help in solving this problem will be highly apprciated. Stefano |
Date | 2018-09-14 07:07 |
From | Steven Yi |
Subject | Re: [Csnd] Cs for Android - problem with "intelligent" pitch shifter |
Can you describe the "not harmonized correctly" a bit more? (Or post an audio example perhaps?) That might give some clues as to where to diagnose. Also, are you running the test csd on Android as well, or are you running it on desktop or other platform? If different platforms, there's a possibility there could be an issue with floating point representation used (the Android build is using 32bit float vs. 64bit double on desktop), either inherently or due to some code not being properly working for 32-bit. On Thu, Sep 13, 2018 at 9:56 AM <00000008a49663bc-dmarc-request@listserv.heanet.ie> wrote: > > Dear list, > > I'm creating a multieffect processor for Csound For Android, here is the github link https://github.com/triceratupuz/matrix-processor > > I've added an intelligent pitch shifter (harmonizer) as instr 155 of the file mat_proc_tpz.csd, the problem is that the produced notes are not harmonized correctly, I've copied the same code in a dedicated csd (see file harmonizerTest_minus.csd in the tests folder) and it works correctly. > > I don't understand why the same code produces wrong result in one case since the difference is basically that instead of reading/writing directly audio with inch/outs it reads and write audio in arrays; the parameters k variables (named kpar1, kpar2, kpar3) seems to receive/produce the same values. > > Any help in solving this problem will be highly apprciated. > Thank you in advance > > Stefano > > Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here |
Date | 2018-09-14 08:30 |
From | 00000008a49663bc-dmarc-request@LISTSERV.HEANET.IE |
Subject | Re: [Csnd] Cs for Android - problem with "intelligent" pitch shifter |
I'll try to be more clear: I play a guitar that goes into the software via audio in; let say I select tonality of C (kpar1 at 0 converted into a midi note by kpar1 * 11 = 0) an I want to harmonize by thirds (kpar2 around 0.33 that is used to index at iintervals ftable index int(0.33 *6) ~= 2). With the standalone program what I hear (instr 1 harmonizerTest_minus.csd): transposition of maj third for C, minor third for D, and so on (correct intervals); with the same code into the main program (instr 155 mat_proc_tpz.csd): transposition of maj third for C, major third for D, a second for E, and so on (wrong intervals). Here is the explaination of the harmonizer code (but i think is not the problem since in the standalone program it works): 0) it has the following controls, kpar1 (range 0-1) set the key (multiplied by 11, 0 for C, 2 for D...),kpar2 (range 0-1) set the inteval (multiplied by 6, 0 unison, 1 second, 2 third,... used as index for iintervals table), kpar3 set the octave ( above, below). iintervals contains major intrvals in semitones, iscala contains the shape of a major scale (1 is a note, 0 is not). 1) incoming audio is analized by pvs opcodes, its frequency is extracted an converted to midi note value. 2) midi note is verified if part of the scale: difference with selected tonality gives the number of semitones to be used as index for table iscala, if tab return 1 note is part of the scale otherwise midi note value is incremented until iscala table returns a 1 3) the transopsing interval selected is retrived from table iintervals (major intrvals in semitones) 4) the index of the "correct" note (see point2) is incremented by the interval in semitones ( % 12 to remain in table boundaries), interval is decremented if necessary (to search minor intervals if needed) until iscala tab return 1. 5) the interval calculated is used to calculate th ratio used pitch shift the note with pvshift One difference between the two programs is audio input, direct reading from inc Vs reading the audio signal from an audio array (macro INMIXT is a mixer to sum audio signal passed throug an array). Both programs are run with csound for android 6.10 (not 6.11 since it has no selection of audio drivers an give me worst audio performance) on the same tablet, with same sr, ksmps, -b and -B. Hope this clarify how it doesen't work. > Il 14 settembre 2018 alle 8.07 Steven Yi |
Date | 2018-09-14 08:52 |
From | Victor Lazzarini |
Subject | Re: [Csnd] Cs for Android - problem with "intelligent" pitch shifter |
is your desktop test with 6.10 or 6.11? Victor Lazzarini Dean of Arts, Celtic Studies, and Philosophy Maynooth University Ireland > On 14 Sep 2018, at 08:30, "00000008a49663bc-dmarc-request@LISTSERV.HEANET.IE" <00000008a49663bc-dmarc-request@LISTSERV.HEANET.IE> wrote: > > I'll try to be more clear: I play a guitar that goes into the software via audio in; let say I select tonality of C (kpar1 at 0 converted into a midi note by kpar1 * 11 = 0) an I want to harmonize by thirds (kpar2 around 0.33 that is used to index at iintervals ftable index int(0.33 *6) ~= 2). With the standalone program what I hear (instr 1 harmonizerTest_minus.csd): transposition of maj third for C, > minor third for D, and so on (correct intervals); with the same code into the main program (instr 155 mat_proc_tpz.csd): transposition of maj third for C, major third for D, a second for E, and so on (wrong intervals). > > > Here is the explaination of the harmonizer code (but i think is not the problem since in the standalone program it works): > > 0) it has the following controls, kpar1 (range 0-1) set the key (multiplied by 11, 0 for C, 2 for D...),kpar2 (range 0-1) set the inteval (multiplied by 6, 0 unison, 1 second, 2 third,... used as index for iintervals table), kpar3 set the octave ( above, below). iintervals contains major intrvals in semitones, iscala contains the shape of a major scale (1 is a note, 0 is not). > > 1) incoming audio is analized by pvs opcodes, its frequency is extracted an converted to midi note value. > > 2) midi note is verified if part of the scale: difference with selected tonality gives the number of semitones to be used as index for table iscala, if tab return 1 note is part of the scale otherwise midi note value is incremented until iscala table returns a 1 > > 3) the transopsing interval selected is retrived from table iintervals (major intrvals in semitones) > > 4) the index of the "correct" note (see point2) is incremented by the interval in semitones ( % 12 to remain in table boundaries), interval is decremented if necessary (to search minor intervals if needed) until iscala tab return 1. > > 5) the interval calculated is used to calculate th ratio used pitch shift the note with pvshift > > > One difference between the two programs is audio input, direct reading from inc Vs reading the audio signal from an audio array (macro INMIXT is a mixer to sum audio signal passed throug an array). > > Both programs are run with csound for android 6.10 (not 6.11 since it has no selection of audio drivers an give me worst audio performance) on the same tablet, with same sr, ksmps, -b and -B. > > Hope this clarify how it doesen't work. > > > >> Il 14 settembre 2018 alle 8.07 Steven Yi |
Date | 2018-09-14 09:03 |
From | 00000008a49663bc-dmarc-request@LISTSERV.HEANET.IE |
Subject | Re: [Csnd] Cs for Android - problem with "intelligent" pitch shifter |
No desktop, only android (7.0) tablet with csound for android app 6.10 . Since I'm not using anything special/experimental (pv opcodes, tables, arrays) could it matter? > Il 14 settembre 2018 alle 9.52 Victor Lazzarini |
Date | 2018-09-14 10:04 |
From | Victor Lazzarini |
Subject | Re: [Csnd] Cs for Android - problem with "intelligent" pitch shifter |
I don’t know, but if desktop is 6.11, I wonder if there was something in 6.10 that we fixed. Since we can’t test this ourselves, I would suggest that you could try isolating the differences at stage of the process, if possible. 1) run the android version with the same input mode as the desktop. 2) check that the android pitch tracking is giving the right MIDI note 3) check that al arithmetic expressions are giving the correct result, e.g. if there is rounding or truncation involved. It is possible that errors might have accumulated and the result becomes different in the end. It’s difficult to see where things are not right unless each step is checked. Regarding 6.10 v. 6.11, I’d like to know more about the differences in performance, as I wasn’t aware of it. Is this with the package we release in csound.com/downloads or the Csound app from the google store. If it is the former, we should check that we have not had any regression. We can look at this after we get to the bottom of your current problem. ======================== Prof. Victor Lazzarini Dean of Arts, Celtic Studies, and Philosophy, Maynooth University, Maynooth, Co Kildare, Ireland Tel: 00 353 7086936 Fax: 00 353 1 7086952 > On 14 Sep 2018, at 09:03, 00000008a49663bc-dmarc-request@LISTSERV.HEANET.IE wrote: > > No desktop, only android (7.0) tablet with csound for android app 6.10 . Since I'm not using anything special/experimental (pv opcodes, tables, arrays) could it matter? > >> Il 14 settembre 2018 alle 9.52 Victor Lazzarini |
Date | 2018-09-14 11:41 |
From | 00000008a49663bc-dmarc-request@LISTSERV.HEANET.IE |
Subject | Re: [Csnd] Cs for Android - problem with "intelligent" pitch shifter |
Victor, I'll try to create a less minimal file, maybe the problem lies in instruments activation or how values are passed (this was already verified but will have another look). just to be sure, the csound version is the same, the machine is the same(only the tablet for my test), no desktop computer involved anyhow. I'm using 6.10 from google store, 6.11 does not allow to choose the audio driver, it is default to Oboe but I have far better performance (less audio dropouts) with OpenSLES hence i stay with 6.10.
|
Date | 2018-09-14 13:18 |
From | Victor Lazzarini |
Subject | Re: [Csnd] Cs for Android - problem with "intelligent" pitch shifter |
Thanks. We’ll wait to hear. Regarding Csound for Android at the Google app store, Michael Gogins maintains it, and I am sure he would be interested to hear your reports re: audio backend issues. best ======================== Prof. Victor Lazzarini Dean of Arts, Celtic Studies, and Philosophy, Maynooth University, Maynooth, Co Kildare, Ireland Tel: 00 353 7086936 Fax: 00 353 1 7086952 > On 14 Sep 2018, at 11:41, 00000008a49663bc-dmarc-request@LISTSERV.HEANET.IE wrote: > > Victor, > > I'll try to create a less minimal file, maybe the problem lies in instruments activation or how values are passed (this was already verified but will have another look). > > just to be sure, the csound version is the same, the machine is the same(only the tablet for my test), no desktop computer involved anyhow. > > I'm using 6.10 from google store, 6.11 does not allow to choose the audio driver, it is default to Oboe but I have far better performance (less audio dropouts) with OpenSLES hence i stay with 6.10. > > Il 14 settembre 2018 alle 11.04 Victor Lazzarini |
Date | 2018-09-17 20:02 |
From | 00000008a49663bc-dmarc-request@LISTSERV.HEANET.IE |
Subject | Re: [Csnd] Cs for Android - problem with "intelligent" pitch shifter |
ah ah problem solved, I simply calculated wrong octave multiplier but I was monitoring everything but not this. I already asked Micael Gogins to restore driver selection, looking forward to 6.12 Bye > Il 14 settembre 2018 alle 14.18 Victor Lazzarini |