[CLAM] Need help
Stephane THOMAS
sthomas at nerim.net
Wed Dec 10 08:53:52 PST 2008
Hello,
I try to modify the example program
http://iua-share.upf.edu/wikis/clam/index.php/Constructing_and_playing_a_simple_network
I want to use a MultiChannelAudioFileReader instead of the mono one, and use JACKNetworkPlayer instead of the PortAudio player.
Changing :
network.SetPlayer(new CLAM::PANetworkPlayer);
with :
CLAM::JACKNetworkPlayer player;
network.SetPlayer (&player);
works fine with the MonoAudioFileReader.
But I want to use a multi-channel reader (to play a stereo file) so my code becomes :
-----main.cpp----------
#include <CLAM/Network.hxx>
#include <CLAM/PANetworkPlayer.hxx>
#include <CLAM/JACKNetworkPlayer.hxx>
#include <CLAM/MultiChannelAudioFileReader.hxx>
int error(const std::string & msg)
{
std::cerr << msg << std::endl;
return -1;
}
int main(int argc, char ** argv)
{
if (argc!=2) return error ("needs a filename.");
CLAM::Network network;
std::string reader = network.AddProcessing("MultiChannelAudioFileReader");
// Configure the reader
CLAM::MultiChannelAudioFileReaderConfig cfg;
cfg.SetSourceFile(argv[1]);
if (!network.ConfigureProcessing(reader, cfg))
return error("Could not open the file");
int length = ((CLAM::MultiChannelAudioFileReader &) network.GetProcessing(reader)).GetHeader().GetLength()/1000;
// Add an audio sink and connect its input to the reader's output
std::string sinkL = network.AddProcessing("AudioSink");
std::string sinkR = network.AddProcessing("AudioSink");
network.ConnectPorts(reader+".Channel #0", sinkL+".AudioIn");
network.ConnectPorts(reader+".Channel #1", sinkR+".AudioIn");
// Set the audio backend to PortAudio
//network.SetPlayer(new CLAM::PANetworkPlayer);
// What's about JACK ?
CLAM::JACKNetworkPlayer player;
network.SetPlayer (&player);
network.Start();
sleep(length);
network.Stop();
}
---------------------------
I can see a JACK client in qjackctl, if I connect it I have the audio file played crackling...
In the console output I have this error message repeated:
Warning: 2 sinks were not fed, so could not send audio to the callback.
What's wrong ?
Stef
PS: I have been able to ouput sound correctly in JACK with another program I made. But I had some strange behaviors, that's why I first want to try to modify this example...
PPS: When using the original example with portaudio, the sound output is pitched up, I guess there is a bitrate problem...(48000 vs 44100)
More information about the clam-users
mailing list