Csound Csound-dev Csound-tekno Search About

[Csnd] roundoff errors in cpspch?

Date2009-07-30 20:52
Fromjoachim heintz
Subject[Csnd] roundoff errors in cpspch?
As I am working about some microtonal calculations, I came across to  
some results of the cpspch opcode. Starting from a = 880 Hz, the first  
column is calculated by multiplying with 2^(1/12), 2^(2/12) etc, the  
second column by cpspch(9.10), cps(9.11) etc:

2^(n/12)		cpspch
932.327576		932.274902
987.766602		987.738770
1046.502197		1046.502197
1108.730591		1108.667969
1174.659058		1174.625977
1244.507935		1244.402588
1318.510254		1318.435913
1396.912964		1396.873413
1479.977661		1479.977661
1567.981689		1567.893311

The results in the left column are totally in concordance with the  
tables which I found in books and also with Appendix A in the Manual.  
But where come the values in the right column?

Best -

	joachim






gipch ftgen 1, 0, -11, -2, 9.10, 9.11, 10, 10.01, 10.02, 10.03, 10.04,  
10.05, 10.06, 10.07, 10.08
instr 1
istartcps = 880
istep = 1
loop:
ia = istartcps * 2 ^ (istep/12)
ipch tab_i istep-1, 1
ib = cpspch(ipch)
prints "%f	%f%n", ia, ib
loop_lt istep, 1, 11, loop
endin


i 1 0 .1



Date2009-07-30 21:43
FromAlan Peter Fitch
Subject[Csnd] Re: roundoff errors in cpspch?
joachim heintz wrote:
> As I am working about some microtonal calculations, I came across to  
> some results of the cpspch opcode. Starting from a = 880 Hz, the first  
> column is calculated by multiplying with 2^(1/12), 2^(2/12) etc, the  
> second column by cpspch(9.10), cps(9.11) etc:
> 
> 2^(n/12)		cpspch
> 932.327576		932.274902
> 987.766602		987.738770
> 1046.502197		1046.502197
> 1108.730591		1108.667969
> 1174.659058		1174.625977
> 1244.507935		1244.402588
> 1318.510254		1318.435913
> 1396.912964		1396.873413
> 1479.977661		1479.977661
> 1567.981689		1567.893311
> 
> The results in the left column are totally in concordance with the  
> tables which I found in books and also with Appendix A in the Manual.  
> But where come the values in the right column?
> 
> Best -
> 
> 	joachim
> 
> 
> 
> 
> 
> 
> gipch ftgen 1, 0, -11, -2, 9.10, 9.11, 10, 10.01, 10.02, 10.03, 10.04,  
> 10.05, 10.06, 10.07, 10.08
> instr 1
> istartcps = 880
> istep = 1
> loop:
> ia = istartcps * 2 ^ (istep/12)
> ipch tab_i istep-1, 1
> ib = cpspch(ipch)
> prints "%f	%f%n", ia, ib
> loop_lt istep, 1, 11, loop
> endin
> 
> 
> i 1 0 .1
> 
> 
> 
> 
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
> 

Is this note from the manual the answer to your question?

"[Note]   	Note

The conversion from pch, oct, or midinn into cps is not a linear
operation but involves an exponential process that could be
time-consuming when executed repeatedly. Csound now uses a built-in
table lookup to do this efficiently, even at audio rates. Because the
table index is truncated without interpolation, pitch resolution when
using one of these opcodes is limited to 8192 discrete and equal
divisions of the octave, and some pitches of the standard 12-tone
equally-tempered scale are very slightly mistuned (by at most 0.15 cents). "

regards
Alan

-- 
Alan Fitch

Date2009-07-31 08:18
Fromjoachim heintz
Subject[Csnd] Re: Re: roundoff errors in cpspch?
Oh yes, thanks. I didn't see this note. Best -
	joachim



Am 30.07.2009 um 22:43 schrieb Alan Peter Fitch:

> joachim heintz wrote:
>> As I am working about some microtonal calculations, I came across to
>> some results of the cpspch opcode. Starting from a = 880 Hz, the  
>> first
>> column is calculated by multiplying with 2^(1/12), 2^(2/12) etc, the
>> second column by cpspch(9.10), cps(9.11) etc:
>>
>> 2^(n/12)		cpspch
>> 932.327576		932.274902
>> 987.766602		987.738770
>> 1046.502197		1046.502197
>> 1108.730591		1108.667969
>> 1174.659058		1174.625977
>> 1244.507935		1244.402588
>> 1318.510254		1318.435913
>> 1396.912964		1396.873413
>> 1479.977661		1479.977661
>> 1567.981689		1567.893311
>>
>> The results in the left column are totally in concordance with the
>> tables which I found in books and also with Appendix A in the Manual.
>> But where come the values in the right column?
>>
>> Best -
>>
>> 	joachim
>>
>>
>> 
>> 
>> 
>> 
>> gipch ftgen 1, 0, -11, -2, 9.10, 9.11, 10, 10.01, 10.02, 10.03,  
>> 10.04,
>> 10.05, 10.06, 10.07, 10.08
>> instr 1
>> istartcps = 880
>> istep = 1
>> loop:
>> ia = istartcps * 2 ^ (istep/12)
>> ipch tab_i istep-1, 1
>> ib = cpspch(ipch)
>> prints "%f	%f%n", ia, ib
>> loop_lt istep, 1, 11, loop
>> endin
>> 
>> 
>> i 1 0 .1
>> 
>> 
>>
>>
>> Send bugs reports to this list.
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
>> "unsubscribe csound"
>>
>
> Is this note from the manual the answer to your question?
>
> "[Note]   	Note
>
> The conversion from pch, oct, or midinn into cps is not a linear
> operation but involves an exponential process that could be
> time-consuming when executed repeatedly. Csound now uses a built-in
> table lookup to do this efficiently, even at audio rates. Because the
> table index is truncated without interpolation, pitch resolution when
> using one of these opcodes is limited to 8192 discrete and equal
> divisions of the octave, and some pitches of the standard 12-tone
> equally-tempered scale are very slightly mistuned (by at most 0.15  
> cents). "
>
> regards
> Alan
>
> -- 
> Alan Fitch
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
> "unsubscribe csound"
>