new code:
getNextAudioBlock(const AudioSourceChannelInfo & bufferToFill) {
// Bouml preserved body begin 0007550D
if(finished)return;
finished = true;
for(int voiceNo = virtualVoices.size() ; -- voiceNo >= 0; )
{
if(virtualVoices[voiceNo]->finished)
{
continue;
}
else
{
finished = false;
tempBuffer.numSamples = bufferToFill.numSamples;
tempBuffer.startSample = bufferToFill.startSample;
virtualVoices[voiceNo]->getNextAudioBlock(tempBuffer);
for(int chan = bufferToFill.buffer->getNumChannels(); -- chan >= 0; )
{
bufferToFill.buffer->addFrom(chan,bufferToFill.startSample,*tempBuffer.buffer,chan,bufferToFill.startSample,bufferToFill.numSamples);
}
}
}
// Bouml preserved body end 0007550D
}
tempBuffer is now allocated once in the constructor.
offsets as suggested (i’p pretty confident in what i’m doing there to begin with, i mean, i don’t program software by guessing ;))
but still ! same problem!
again, this,:
getNextAudioBlock(const AudioSourceChannelInfo & bufferToFill) {
// Bouml preserved body begin 0007550D
if(finished)return;
finished = true;
for(int voiceNo = virtualVoices.size() ; -- voiceNo >= 0; )
{
if(virtualVoices[voiceNo]->finished)
{
continue;
}
else
{
virtualVoices[voiceNo]->getNextAudioBlock(bufferToFill);
}
}
// Bouml preserved body end 0007550D
}
works (sounds “clean”), the “voices” overwrite each other thought :(, wich is what i try to avoid in the end.
a “voice” is just a wrapper around an AudioFormatReaderSource (because i want to play any PositionableAudioSource through this mechanism).
there is something similar i do in the SynthesizerVoice code:
renderNextBlock(AudioSampleBuffer & outputBuffer, int startSample, int numSamples) {
// Bouml preserved body begin 0006BC0D
tempBuffer.startSample = 0;
tempBuffer.numSamples = numSamples;
if(this->plays && !zone->getMuted() && zone->isPlaying()){
zoneReader->getNextAudioBlock(tempBuffer);
for(int chan = outputBuffer.getNumChannels(); -- chan >= 0; )
{
outputBuffer.addFrom(chan,startSample,*tempBuffer.buffer,chan,0,numSamples,this->velocity * zone->getVolume(chan));
}
}
else
{
stopNote(false);
}
// Bouml preserved body end 0006BC0D
}
again, this works perfectly fine. and here i do exactly what i try to do in the other code!
the “zonereader” is just a wrapper around a “ResamplingAudioSource”, wich reads from the problematic code.
(pleas don’t question why there is a wrapper around the ResamplingAudioSource. i tested a pattern wich proved to be bad,
but decidet to let this wrapping layer implelemtned, as i might need an abstraction layer at this position later anyways.
i can handle this code easyly (just changed the buffer to be allocated once at construction time in this place too), ther is no room for speculations (to my humble view at least), i’m confidetn in what i’m coding there, this is why i need your help!
i need new perspectives, as i really can’t explain whats wrong here
i have not the slightes idea what i’m doing wrong.
btw. i hear the question coming:" why all the fuzz? two voice managament systmes?"
as in flavour of the last responses (the question why i dont put the stuff into my voice and add it to the buffer there to begin with, for example;) .with the temp buffer it is now even a tad more memory friendly [not that i care that much about memory],as i can share the same temp buffer along all voices!)
i just used the synhtesizer class to begin with to manage keyboard mapping (i’ll optimize it in the end) but since i’m doing retriggered sample playback, i want to “declick” transitions betweend low frequency heavy material. sub kicks for example to horrible klicking when retriggering.
i could have used another synth, but i juts wanted to try (as opposed to my “avoid optimizations at the beginning” philosophy) to make a barebone voicemanagement for “declicking voices”.
i must admit i could have asked how to implmement clickles voice steeling, but i had the feeling i would ask for too much…may i ask now blush? and also, how would you make reverse buffer playback? i mean i could do it i guess, i’d just “iterate” through th epositionable audio source backwards and reverse the buffers. but any, but maybe one of you wan to share thei stuff?
thanks!
D3CK
p.s.: maybe one would like to move this into audio section 
i’d happily get a moderator for this board, as i may be very active here in the next time anyways
i’m not natively english though (i guess u already knew)