[CLAM] What's wrong with my code
Stephane THOMAS
sthomas at nerim.net
Wed Dec 10 09:54:07 PST 2008
Hi,
Here is another program I wrote from scratch (the goal is to get a command line program which plays a stereo file through JACK)
It produces sound, but once again, I have a repeated error message and the sound is awful :
Warning: 2 sinks were not fed, so could not send audio to the callback.
The program is called cjap (for CLAM JACK Audio Player), here is the code :
-----------cjap.h--------------
#include <QObject>
#include "CLAM/Network.hxx"
#include "CLAM/AudioSink.hxx"
#include "CLAM/MultiChannelAudioFileReader.hxx"
#include "CLAM/JACKNetworkPlayer.hxx"
using namespace std;
using namespace CLAM;
class JackAudioFilePlayer : QObject
{
Q_OBJECT
Network network;
AudioSink sinkL;
AudioSink sinkR;
MultiChannelAudioFileReader reader;
MultiChannelAudioFileReaderConfig config;
JACKNetworkPlayer player;
public:
JackAudioFilePlayer ();
void loadfile (string filename);
public slots:
void play ();
void stop ();
};
---------------------------------
-------------cjap.cpp------------------
#include "cjap.h"
JackAudioFilePlayer::JackAudioFilePlayer ()
{
network.AddProcessing("left",&sinkL);
network.AddProcessing("right",&sinkR);
network.AddProcessing("reader",&reader);
}
void JackAudioFilePlayer::loadfile (string filename)
{
config.SetSourceFile(filename);
reader.Configure (config);
network.ConnectPorts("reader.Channel #0","left.AudioIn");
network.ConnectPorts("reader.Channel #1","right.AudioIn");
network.SetPlayer (&player);
}
void JackAudioFilePlayer::play ()
{
network.Start();
}
void JackAudioFilePlayer::stop ()
{
network.Stop();
}
------------------------------------------
----------main.cpp-----------------------
#include <iostream>
#include <QCoreApplication>
#include "cjap.h"
using namespace std;
int main (int argc, char** argv)
{
QCoreApplication app (argc,argv);
if (argc != 2)
{
cout << "Usage: cjap <filename>" << endl;
return 0;
}
else
{
JackAudioFilePlayer* jafp = new JackAudioFilePlayer;
jafp->loadfile(argv[1]);
jafp->play();
}
return app.exec();
}
________________________________________
Stef
More information about the clam-users
mailing list