Passing arguments to a base-class constructor

IC7410faq

This is another FAQ, which I did not know.

% sprigmm hw:2,0 hw:1,0

Here the device names hw:2,0 and hw:1,0 are for IC-7410 and Soft66LC4, respectively.

	Usbsound *mydevice[2]; /* I have two usb sound devices */
	mydevice[0] = new Usbsound_mono{argv[1]}; /* this is IC-7410 */
	mydevice[1] = new Usbsound_iq  {argv[2]}; /* this is Soft66LC4 */

The two usb sound devices behave similarly and and they are both derived from a base-class Usbsound.

class Usbsound_mono: public Usbsound {
public:
	Usbsound_mono();
	Usbsound_mono(char *s);
	virtual ~Usbsound_mono();
};
class Usbsound_iq: public Usbsound {
public:
	Usbsound_iq();
	Usbsound_iq(char *s);
	virtual ~Usbsound_iq();
};

The device name for each sound device, eg. hw:2,0, must be passed to the base-class constructor, Usbsound::Usbsound, for initialization.

Usbsound_mono::Usbsound_mono(char* s) : Usbsound(s) {
	rate        = 32000;
	buffer_size = 32 * 1024;
	period_size =  8 * 1024;
}
Usbsound_iq::Usbsound_iq(char* s) : Usbsound(s)  {
	rate        = 48000;
	buffer_size = 96 * 1024;
	period_size =  2 * 1024;
}

The bit rate and other related parameters are specific for each device.

Leave a Reply

Your email address will not be published. Required fields are marked *