at the moment i use
intvalue = (floatvalue * 32767) div 1
to force the value to be Int16 but I assume thats not how is done usually?
and another qustion I have is is there a quick and elegant way to have linear interpooation
on the wavetable generator?
I assume it coukd be hacked with two voices playing a sample apart and adjusting the volume each tick but than it seems more resonable to make a custom player.
and another qustion is, is there a way to relate the output of rand() to a seed?
for many RND generators the output and input is the same number
like
a = rand()
b = rand()
c = rand()
rand_ seed(a)
rand() == b
but this seems not the case here?
proper way to cnvert float to int16 and otherr questions
- NightRadio
- Site Admin
- Posts: 3955
- Joined: Fri Jan 23, 2004 12:28 am
- Location: Ekaterinburg. Russia
- Contact:
Re: proper way to cnvert float to int16 and otherr questions
Actually this is correct way :)intvalue = (floatvalue * 32767) div 1
to force the value to be Int16 but I assume thats not how is done usually?
Another (maybe a bit faster) way: intvalue = (floatvalue * 32767) |0
Use FLOAT32 table and destination container - in this case linear interpolation will be usedis there a quick and elegant way to have linear interpooation
on the wavetable generator?
Not for rand() unfortunately.is there a way to relate the output of rand() to a seed?
for many RND generators the output and input is the same number
But you can use your own random generator based on this code:
rand_next = rand_next * 1103515245 + 12345
Re: proper way to cnvert float to int16 and otherr questions
Thanks.
I will probably use shift registers for speed.
Background is that I have a nice synthesis that is based on derivatives of impulse responses.
And the idea is for a fast synthesis you can use a sequence from a random number generator instead of sample lookup. I think thats faster, but I am not sure, at any rate you can implement it in hardware without memory.
You search for the right sequence seed offline.
It works surprisungly well ( the samples are not transposed but synched with constant pitch)
I will probably use shift registers for speed.
Background is that I have a nice synthesis that is based on derivatives of impulse responses.
And the idea is for a fast synthesis you can use a sequence from a random number generator instead of sample lookup. I think thats faster, but I am not sure, at any rate you can implement it in hardware without memory.
You search for the right sequence seed offline.
It works surprisungly well ( the samples are not transposed but synched with constant pitch)