I have made a DSP, which I want to work as follows:
1) Get X samples of data from a stream of sound, where X can be any supplied number of samples/bytes.
2) Process samples.
3) Return Y samples to the next DSP, where Y != X. I want to make changes to the sound that makes it shorter or longer (including other changes), depending on the samples.
Since FSOUND_DSPCALLBACK only supplies the number of incoming samples (pass by value), I can’t tell FSOUND how many samples I return. It is easy if I Y>X since then I can keep some samples to the next time my callback is invoked, but what do I do when I X>Y ? (And what do I do if I have remaining samples in my DSP when the sound ends, and I get no more DSP callbacks?)
My first idea was to use FSOUND_SetFrequency or FSOUND_SetBufferSize, but that is a real pain since it can’t be used since I already have the samples, and I don’t know in advance whay Y should be.
I have had some thoughts on running 2 streams. One for reading and supplying my DSP with data, and one that reads from memory, memory which my DSP in the first stream writs into… but that can’t be the right way…
Please help me get back on track…
- kittelmann asked 13 years ago
I thought that fmod worked like this:
It read data from disk/memory.
It passed the data to the dsp’s.
It took the data from the dsp’s and put it in a queue, which it tried to keep at buffersize (set by FSOUND_SetBufferSize). If the buffer contained less than buffersize, then it read more data from disk/memory and passed it to the dsp’s, hoping to get more data in the queue.
There must be some way to change the tempo of the sound, without using setFrequency (which would affect all dsp’s, and their use of the frequency)
- kittelmann answered 13 years ago
I think using setFrequency is the easiest way.
If you have other dsp’s that are frequency-dependent, you should simply calculate the new frequency or length by multiplying it with newFrequency / originalFrequency
If you want to use it to alter the speed withouth altering the pitch, the easiest way would be to use setFrequency, and then apply an algorithm that changes pitch withouth changing length.
- Adion answered 13 years ago
Please login first to submit.