[Stk] RtAudio multiple channel input/output

dimoni at dimoni.demon.nl dimoni at dimoni.demon.nl
Sun Oct 17 12:48:16 PDT 2004


Hi Gary et al.,

I am trying to get multiple input/output channels with a Digi002r from 
Digidesign but I am running into problems.
I have tested if I can get multiple input from other sound cards and I 
get the same errors  although when running probe.cpp from the tutorial 
I obtain the correct information for each device.

Output from probe.cpp:

device = 1
: maximum output channels = 8
: maximum input channels = 2
duplex = 2
device = 2
: maximum output channels = 2
: maximum input channels = 2
duplex = 2
device = 3
: maximum output channels = 18
: maximum input channels = 18
duplex = 18

I have split your code in order to have an audio class where I define 
the process and stop member functions.

AudioClass.cpp code:

#include <iostream>
#include <stk/RtAudio.h>

class AudioClass
{
	int SR;
	int nBuffers;
	int bufferSize;
	int inputChannels, outputChannels;
	int inputDevice, outputDevice;
	RtAudio *audio;
	
public:
	AudioClass( int inputDevice,int inputChannels, int outputDevice, int 
outputChannels, int SR, int bufferSize, int nBuffers)
	{
		this -> SR = SR;
		this -> nBuffers = nBuffers;
		this -> bufferSize = bufferSize;
		this -> inputChannels = inputChannels;
		this -> outputChannels = outputChannels;

		this -> inputDevice = inputDevice;
		this -> outputDevice = outputDevice;
		this -> SR = SR;
		
		try
		{
			audio = new RtAudio(inputDevice, inputChannels, outputDevice, 
outputChannels,
								RTAUDIO_FLOAT64, SR, &bufferSize, nBuffers);
		}
		
		catch (RtError &error)
		{
			error.printMessage();
			exit(EXIT_FAILURE);
		}
	}
	
	~AudioClass()
	{
		delete audio;
	}
	
	void ProcessAudio(int Callback)
	{
		try
		{
			audio->setStreamCallback(/*&AudioClass::*/Callback, NULL); // Set 
the stream callback function
			audio->startStream(); // Start the stream
		}
		catch (RtError &error)
		{
			error.printMessage();
			exit(1);
		}
	}
		
	void StopAudio()
	{
		try
		{
			// Stop and close the stream
			audio->stopStream();
			audio->closeStream();
		}
		catch (RtError &error)
		{
			error.printMessage();
			exit(1);
		}
	}
}; //end of AudioClass


******* Main code: *******


#include <iostream>
#include "AudioClass.cpp"

int Callback( char *buffer, int bufferSize, void *userData)
         {
                 // Note: do nothing here for pass through.
                 double *my_buffer = (double *) buffer;

                 // Scale input data for output.
                 for (int i=0; i<bufferSize; i++) {
                         // Do for two channels.
                        *my_buffer++ *= 0.9;
                         *my_buffer++ *= 0.9;
                 }

                 return 0;
         }

int main()
{
	char input;
	AudioClass audio(3, 0, 3, 4, 44100, 256, 4);
	
	audio.ProcessAudio(&Callback);
	std::cout << "\nRunning duplex ... press <enter> to quit.\n";
	std::cin.get(input);
	audio.StopAudio();
	
	return 0;
}

After running it, I get the following error:

"
RtApi: unable to open specified device(s) with given stream parameters:
     RtApiCore: OS-X error getting stream format for device (Digidesign: 
Digidesign HW ( 002 )).

rtAudioInOut has exited with status 1.
"
I have run the same code by providing 2 inputs and 2 outputs and it 
works fine.
In order to test if there was a hardware problem, I have tried to get 
multiple outputs by using PortAudio and had no problems.
Is there anything I am missing in my code?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 6706 bytes
Desc: not available
URL: <https://cm-mail.stanford.edu/pipermail/stk/attachments/20041017/a6a00529/attachment.bin>


More information about the Stk mailing list