Csound Csound-dev Csound-tekno Search About

Re: when 52450 becomes 0.0052480.00

Date1999-09-18 05:14
FromHans Mikelson
SubjectRe: when 52450 becomes 0.0052480.00
>> FTERROR, ftable 10: illegal table length
>> f 10   0.0052480.00    1.00  "Sound.aif" ...


Hi,

One other thing that confused me when I first started working with the
granular opcodes is that the frequency you ask for is the number of times
the entire table is cycled per second.  If you have a sample of a sound at a
certain frequency you need to do some calculations if you want your
granulized sample tuned to a certain pitch.

For example suppose you have a sample of a 400 Hz pitched sound that lasts 2
seconds and has a sample rate of 44100 Hz and is monophonic.  This means it
has 88200 samples.  The smallest power of 2 that will hold this many samples
is 2^17=131072.  The number of seconds in this many samples at a 44100
sample rate is about 2.97215 seconds.  In order for the sound to play at 400
Hz you would need to use a frequency of 1/2.97215=.336456

When I first started working with the granular opcodes I think I tried
things like 400 Hz, 1 Hz and .5 Hz before I figured it out.

A formula for this would be something like:

TableSize = 2^(int(logbase2(SampleDuration*SampleSR))+1)

OutputFrequency = (DesiredFrequency/SampleFrequency)/(TableSize/OrcSR)

Which I think will work except for when the size of the sample is exactly
equal to a power of two.  Then don't add one.

Now wasn't that confusing?  Or am I just confused?

Bye,
Hans Mikelson