[Csnd] Odd result summing sinewaves into a square wave.
Date | 2009-12-11 22:07 |
From | Tobiah |
Subject | [Csnd] Odd result summing sinewaves into a square wave. |
I used a single sine oscillator to sum odd harmonics of a base freq, dividing the volume of each by it's harmonic number. Near the beginning of the wave form, it looked just like the text book example of a band limited square wave. Then, after a few seconds, the wave morphed and twisted to one side. Is this because of the limits in floating point precision? All the frequency values are integers. I would have thought that they would all average out and be in sync in the end. Take a look at the waveform. It's sort of interesting. http://tobiah.org/harm.sco http://tobiah.org/harm.wav Thanks, Tobiah Send bugs reports to this list. To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" |
Date | 2009-12-11 23:44 |
From | Richard Dobson |
Subject | [Csnd] Re: Odd result summing sinewaves into a square wave. |
We'd need to see the orc to be sure what was happening, but certainly the behaviour suggests accumulating phase errors, though rather more quickly that I would expect. When I was making real-time additive waveforms using Clearspeed parallel accelerator cards, I did a "soak test" to confirm just this issue - a waveform would start perfectly, and by about 20mins or so the shape would have degraded past the point of recognition. Switching to double precision fixed it - soak tests of several hours showed no visible degradation. This was in respect of the incrementing phase value provided to the sine() function. In your example the phase shifts are occuring, as you say, in a matter of seconds, so something rather drastic is going on. The shape is also degrading more coherently (if that is not an oxymoron); whereas the degradation I saw was somewhat more random. So we need to see the orc file. Richard Dobson Tobiah wrote: > I used a single sine oscillator to sum odd harmonics of a base freq, > dividing the volume of each by it's harmonic number. > > Near the beginning of the wave form, it looked just like the > text book example of a band limited square wave. Then, > after a few seconds, the wave morphed and twisted to one side. > > Is this because of the limits in floating point precision? All the > frequency values are integers. I would have thought that they > would all average out and be in sync in the end. > > Take a look at the waveform. It's sort of interesting. > > http://tobiah.org/harm.sco > http://tobiah.org/harm.wav > > Thanks, > > Tobiah > > > Send bugs reports to this list. > To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" > > Send bugs reports to this list. To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" |
Date | 2009-12-11 23:54 |
From | Tobiah |
Subject | [Csnd] Re: Re: Odd result summing sinewaves into a square wave. |
Attachments | harm.orc |
> We'd need to see the orc to be sure what was happening I didn't include it because it was just a single sine oscillator. Here it is. Tobiah Send bugs reports to this list. To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" |
Date | 2009-12-11 23:56 |
From | Tobiah |
Subject | [Csnd] Re: Re: Odd result summing sinewaves into a square wave. |
> We'd need to see the orc to be sure what was happening, Or here: http://tobiah.org/harm.orc I can't paste it into the email because of gmail and tabs. Send bugs reports to this list. To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" |
Date | 2009-12-12 01:28 |
From | Richard Dobson |
Subject | [Csnd] Re: Re: Re: Odd result summing sinewaves into a square wave. |
Hmm, well, there is more than one way to generate a sine, needed to be sure. It is actually IMO very odd; I had not expected oscili to be so vulnerable. The thing is, unless the code has been completely changed, this is the classic power-of-two limited oscili, which actually does integer arithmetic for speed. 32bits are distributed between the index into the table and the fractional increment. The larger the table, the smaller the number of bits available to compute the phase increment (it becomes quantised, in effect). Definitely worth investigation (but not by me just now - got too much on at the moment). We should, indeed reasonably expect a sine osc to maintain exact phase for a very long time! Richard Dobson Tobiah wrote: >> We'd need to see the orc to be sure what was happening > > I didn't include it because it was just a single sine oscillator. > Here it is. > > Tobiah > > Send bugs reports to this list. > To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" Send bugs reports to this list. To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" |
Date | 2009-12-12 02:52 |
From | Victor Lazzarini |
Subject | [Csnd] Re: Re: Re: Re: Odd result summing sinewaves into a square wave. |
I am not sure what you are getting but I put Tobiah's instrument in the CSD below and I get a square wave that does not seem to change shape too much at all. |
Date | 2009-12-12 04:46 |
From | Peiman Khosravi |
Subject | [Csnd] pvsbandp and phase |
Hello, One question. Why do pvsbandp and pvsbandr mess up the phase in the pvs signal? Shouldn't they only act on the amplitude data, keeping the frequencies intact? Best Peiman Send bugs reports to this list. To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" |
Date | 2009-12-12 10:44 |
From | Richard Dobson |
Subject | [Csnd] Re: Re: Re: Re: Re: Odd result summing sinewaves into a square wave. |
Did you try it with his original score etc? Among other things You have a much higher fundamental (400 rather than 70). Clearly the effect is frequency-related. Richard Dobson Victor Lazzarini wrote: > I am not sure what you are getting but I put Tobiah's instrument in the > CSD below and I get a square wave that does not seem to change shape too > much at all. > .. > i_pitch init p4*400 > ;***** SYNTH ***** > a_sig oscili i_vol, i_pitch, 1 > outs a_sig * gi_master_vol, a_sig * gi_master_vol > endin > > |
Date | 2009-12-12 12:30 |
From | Victor Lazzarini |
Subject | [Csnd] Re: Re: Re: Re: Re: Re: Odd result summing sinewaves into a square wave. |
I didn't see the original score. I'l try. On 12 Dec 2009, at 10:44, Richard Dobson wrote: > Did you try it with his original score etc? Among other things You > have a much higher fundamental (400 rather than 70). Clearly the > effect is frequency-related. > > > Richard Dobson > > > Victor Lazzarini wrote: >> I am not sure what you are getting but I put Tobiah's instrument in >> the CSD below and I get a square wave that does not seem to change >> shape too much at all. > .. >> i_pitch init p4*400 >> ;***** SYNTH ***** >> a_sig oscili i_vol, i_pitch, 1 >> outs a_sig * gi_master_vol, a_sig * gi_master_vol >> endin >> >> |
Date | 2009-12-12 12:41 |
From | Victor Lazzarini |
Subject | [Csnd] Re: Re: Re: Re: Re: Re: Re: Odd result summing sinewaves into a square wave. |
I a slight change in shape over the 30 secs, but not that dramatic. It is definitely a by-product of the integer-maths increment/index calculation (and expected). If you use poscil (which uses double floating-point indexing), it goes away. Maybe we should consider using 64bit integers in oscil and friends when we build csound in 64bit OS machines. Victor On 12 Dec 2009, at 12:30, Victor Lazzarini wrote: > I didn't see the original score. I'l try. > On 12 Dec 2009, at 10:44, Richard Dobson wrote: > >> Did you try it with his original score etc? Among other things You >> have a much higher fundamental (400 rather than 70). Clearly the >> effect is frequency-related. >> >> >> Richard Dobson >> >> >> Victor Lazzarini wrote: >>> I am not sure what you are getting but I put Tobiah's instrument >>> in the CSD below and I get a square wave that does not seem to >>> change shape too much at all. >> .. >>> i_pitch init p4*400 >>> ;***** SYNTH ***** >>> a_sig oscili i_vol, i_pitch, 1 >>> outs a_sig * gi_master_vol, a_sig * gi_master_vol >>> endin >>> >>> |