Struggling to use AudioSource and AudioProcesor together


#1

Sorry to be asking questions that should be obvious from other posts and looking through the demo code, and I think I’m getting close, but it’s just not clicking for me.

What I have done so far is created a basic drum sequencer going the AudioSource way, and have decided it would be nice to add VST’s to it (compression/delay… whatever)

My current setup for the sequencer is a few sampling Synthesisers, with sequence timing in their respective getNextAudioBlock() loops. They all run into a MixerAudioSource, connected to an AudioSourcePlayer, and then to the AudioDeviceManager.

I have tried taking the MixerAudioSource, wrapping it into an AudioProcessor (using the class herehttp://www.rawmaterialsoftware.com/viewtopic.php?f=4&t=3505&start=0&hilit=audioprocessor+speed),
putting it in an AudioProcessGraph with a AudioGraphIOProcessor, linking it all up, and sending it to the AudioDeviceManager via a AudioProcessorPlayer.

It makes sounds, but the sampling rate seems all weird. It seems to be playing the samples back at the right pitch, but seems to be be counting samples, setting block read start samples, and running the sequencer twice as fast as it should. I know that people are busy, and maybe the AudioProcessor chain is not yet ready to use in it’s current state, but someone has figured it out, right? Could I have a hint? Please? with a pint on top?

Edit…
Super dumb question, now with clarity and sunlight I see that I was calling the one AudioSource through both the MixerAudioSource and the AudioProcessor chain. I am, however, having trouble getting AudioSources to start running without them going through an AudioSourcePlayer, so I need to look at that a little more. After lunch, methinks.


#2

No, still not getting it. the SMAudioSourceProcessor is generating sound, I can tell because of getMagnitude(), but my addConnection in the graph is failing. I am not using external midi, just trying the below code

			processorGraph = new AudioProcessorGraph();
			processorGraph->setPlayConfigDetails(0,2,44100,960);
			processorGraph->prepareToPlay(44100,960);
			processorPlayer.setProcessor(processorGraph);
			deviceManager.addAudioCallback(&processorPlayer);
			
			ioProcIn = new AudioProcessorGraph::AudioGraphIOProcessor(AudioProcessorGraph::AudioGraphIOProcessor::audioInputNode);
			ioProcOut = new AudioProcessorGraph::AudioGraphIOProcessor(AudioProcessorGraph::AudioGraphIOProcessor::audioOutputNode);
			ioProcOut->setPlayConfigDetails(2,2,44100,960);

			ioProcInNode = processorGraph->addNode(ioProcIn);
			ioProcOutNode = processorGraph->addNode(ioProcOut);
			mixerWrapper = new SMAudioSourceProcessor(mixer,false);
			DBG(T("samprate:")+String(mixerWrapper->getSampleRate()));
			mixerWrapperNode = processorGraph->addNode(mixerWrapper);
			bool result = processorGraph->addConnection(mixerWrapperNode->id,0,ioProcOutNode->id,0);
			DBG(T("0-0:")+String(result)); //returns 0
			result = processorGraph->addConnection(mixerWrapperNode->id,1,ioProcOutNode->id,1);
			DBG(T("1-1:")+String(result)); //returns 0

I am getting 0 “because you’re trying to connect a midi channel to an audio one or other such nonsense”. I know it’s not midi (quite sure, at any rate), so… what other nonsense might it be?


#3

Sorted it all out. I’m not sure what the magic line was, as I just threw in every command I could out of the API. Now if I trim it back some of the code, I should be able to ascertain what it was.