|
|
|
@ -58,7 +58,7 @@ class K3bSoxProgram : public K3bExternalProgram
|
|
|
|
|
TQFileInfo fi( path );
|
|
|
|
|
if( fi.isDir() ) {
|
|
|
|
|
if( path[path.length()-1] != '/' )
|
|
|
|
|
path.append("/");
|
|
|
|
|
path.append("/");
|
|
|
|
|
path.append("sox");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -75,34 +75,34 @@ class K3bSoxProgram : public K3bExternalProgram
|
|
|
|
|
if( vp.start( TDEProcess::Block, TDEProcess::AllOutput ) ) {
|
|
|
|
|
int pos = out.output().find( "sox: SoX Version" );
|
|
|
|
|
if ( pos < 0 )
|
|
|
|
|
pos = out.output().find( "sox: SoX v" ); // newer sox versions
|
|
|
|
|
pos = out.output().find( "sox: SoX v" ); // newer sox versions
|
|
|
|
|
int endPos = out.output().find( "\n", pos );
|
|
|
|
|
if( pos > 0 && endPos > 0 ) {
|
|
|
|
|
pos += 17;
|
|
|
|
|
bin = new K3bExternalBin( this );
|
|
|
|
|
bin->path = path;
|
|
|
|
|
bin->version = out.output().mid( pos, endPos-pos );
|
|
|
|
|
pos += 17;
|
|
|
|
|
bin = new K3bExternalBin( this );
|
|
|
|
|
bin->path = path;
|
|
|
|
|
bin->version = out.output().mid( pos, endPos-pos );
|
|
|
|
|
|
|
|
|
|
addBin( bin );
|
|
|
|
|
addBin( bin );
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
pos = out.output().find( "sox: Version" );
|
|
|
|
|
endPos = out.output().find( "\n", pos );
|
|
|
|
|
if( pos > 0 && endPos > 0 ) {
|
|
|
|
|
pos += 13;
|
|
|
|
|
bin = new K3bExternalBin( this );
|
|
|
|
|
bin->path = path;
|
|
|
|
|
bin->version = out.output().mid( pos, endPos-pos );
|
|
|
|
|
pos += 13;
|
|
|
|
|
bin = new K3bExternalBin( this );
|
|
|
|
|
bin->path = path;
|
|
|
|
|
bin->version = out.output().mid( pos, endPos-pos );
|
|
|
|
|
|
|
|
|
|
addBin( bin );
|
|
|
|
|
addBin( bin );
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return false;
|
|
|
|
@ -112,7 +112,7 @@ class K3bSoxProgram : public K3bExternalProgram
|
|
|
|
|
|
|
|
|
|
class K3bSoxEncoder::Private
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
public:
|
|
|
|
|
Private()
|
|
|
|
|
: process(0) {
|
|
|
|
|
}
|
|
|
|
@ -183,20 +183,20 @@ bool K3bSoxEncoder::initEncoderInternal( const TQString& extension )
|
|
|
|
|
d->process->setRawStdin(true);
|
|
|
|
|
|
|
|
|
|
connect( d->process, TQ_SIGNAL(processExited(TDEProcess*)),
|
|
|
|
|
this, TQ_SLOT(slotSoxFinished(TDEProcess*)) );
|
|
|
|
|
this, TQ_SLOT(slotSoxFinished(TDEProcess*)) );
|
|
|
|
|
connect( d->process, TQ_SIGNAL(stderrLine(const TQString&)),
|
|
|
|
|
this, TQ_SLOT(slotSoxOutputLine(const TQString&)) );
|
|
|
|
|
this, TQ_SLOT(slotSoxOutputLine(const TQString&)) );
|
|
|
|
|
connect( d->process, TQ_SIGNAL(stdoutLine(const TQString&)),
|
|
|
|
|
this, TQ_SLOT(slotSoxOutputLine(const TQString&)) );
|
|
|
|
|
this, TQ_SLOT(slotSoxOutputLine(const TQString&)) );
|
|
|
|
|
|
|
|
|
|
// input settings
|
|
|
|
|
*d->process << soxBin->path
|
|
|
|
|
<< "-t" << "raw" // raw samples
|
|
|
|
|
<< "-r" << "44100" // samplerate
|
|
|
|
|
<< "-s" // signed linear
|
|
|
|
|
<< "-w" // 16-bit words
|
|
|
|
|
<< "-c" << "2" // stereo
|
|
|
|
|
<< "-"; // read from stdin
|
|
|
|
|
<< "-t" << "raw" // raw samples
|
|
|
|
|
<< "-r" << "44100" // samplerate
|
|
|
|
|
<< "-s" // signed linear
|
|
|
|
|
<< "-w" // 16-bit words
|
|
|
|
|
<< "-c" << "2" // stereo
|
|
|
|
|
<< "-"; // read from stdin
|
|
|
|
|
|
|
|
|
|
// output settings
|
|
|
|
|
*d->process << "-t" << extension;
|
|
|
|
@ -205,28 +205,28 @@ bool K3bSoxEncoder::initEncoderInternal( const TQString& extension )
|
|
|
|
|
c->setGroup( "K3bSoxEncoderPlugin" );
|
|
|
|
|
if( c->readBoolEntry( "manual settings", false ) ) {
|
|
|
|
|
*d->process << "-r" << TQString::number( c->readNumEntry( "samplerate", 44100 ) )
|
|
|
|
|
<< "-c" << TQString::number( c->readNumEntry( "channels", 2 ) );
|
|
|
|
|
<< "-c" << TQString::number( c->readNumEntry( "channels", 2 ) );
|
|
|
|
|
|
|
|
|
|
int size = c->readNumEntry( "data size", 16 );
|
|
|
|
|
*d->process << ( size == 8 ? TQString("-b") : ( size == 32 ? TQString("-l") : TQString("-w") ) );
|
|
|
|
|
|
|
|
|
|
TQString encoding = c->readEntry( "data encoding", "signed" );
|
|
|
|
|
if( encoding == "unsigned" )
|
|
|
|
|
*d->process << "-u";
|
|
|
|
|
*d->process << "-u";
|
|
|
|
|
else if( encoding == "u-law" )
|
|
|
|
|
*d->process << "-U";
|
|
|
|
|
*d->process << "-U";
|
|
|
|
|
else if( encoding == "A-law" )
|
|
|
|
|
*d->process << "-A";
|
|
|
|
|
*d->process << "-A";
|
|
|
|
|
else if( encoding == "ADPCM" )
|
|
|
|
|
*d->process << "-a";
|
|
|
|
|
*d->process << "-a";
|
|
|
|
|
else if( encoding == "IMA_ADPCM" )
|
|
|
|
|
*d->process << "-i";
|
|
|
|
|
*d->process << "-i";
|
|
|
|
|
else if( encoding == "GSM" )
|
|
|
|
|
*d->process << "-g";
|
|
|
|
|
*d->process << "-g";
|
|
|
|
|
else if( encoding == "Floating-point" )
|
|
|
|
|
*d->process << "-f";
|
|
|
|
|
*d->process << "-f";
|
|
|
|
|
else
|
|
|
|
|
*d->process << "-s";
|
|
|
|
|
*d->process << "-s";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*d->process << d->fileName;
|
|
|
|
@ -273,24 +273,24 @@ TQStringList K3bSoxEncoder::extensions() const
|
|
|
|
|
static TQStringList s_extensions;
|
|
|
|
|
if( s_extensions.isEmpty() ) {
|
|
|
|
|
s_extensions << "au"
|
|
|
|
|
<< "8svx"
|
|
|
|
|
<< "aiff"
|
|
|
|
|
<< "avr"
|
|
|
|
|
<< "cdr"
|
|
|
|
|
<< "cvs"
|
|
|
|
|
<< "dat"
|
|
|
|
|
<< "gsm"
|
|
|
|
|
<< "hcom"
|
|
|
|
|
<< "maud"
|
|
|
|
|
<< "sf"
|
|
|
|
|
<< "sph"
|
|
|
|
|
<< "smp"
|
|
|
|
|
<< "txw"
|
|
|
|
|
<< "vms"
|
|
|
|
|
<< "voc"
|
|
|
|
|
<< "wav"
|
|
|
|
|
<< "wve"
|
|
|
|
|
<< "raw";
|
|
|
|
|
<< "8svx"
|
|
|
|
|
<< "aiff"
|
|
|
|
|
<< "avr"
|
|
|
|
|
<< "cdr"
|
|
|
|
|
<< "cvs"
|
|
|
|
|
<< "dat"
|
|
|
|
|
<< "gsm"
|
|
|
|
|
<< "hcom"
|
|
|
|
|
<< "maud"
|
|
|
|
|
<< "sf"
|
|
|
|
|
<< "sph"
|
|
|
|
|
<< "smp"
|
|
|
|
|
<< "txw"
|
|
|
|
|
<< "vms"
|
|
|
|
|
<< "voc"
|
|
|
|
|
<< "wav"
|
|
|
|
|
<< "wve"
|
|
|
|
|
<< "raw";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( k3bcore->externalBinManager()->foundBin( "sox" ) )
|
|
|
|
@ -348,24 +348,24 @@ TQString K3bSoxEncoder::fileTypeComment( const TQString& ext ) const
|
|
|
|
|
long long K3bSoxEncoder::fileSize( const TQString&, const K3b::Msf& msf ) const
|
|
|
|
|
{
|
|
|
|
|
// for now we make a rough assumption based on the settings
|
|
|
|
|
TDEConfig* c = k3bcore->config();
|
|
|
|
|
c->setGroup( "K3bSoxEncoderPlugin" );
|
|
|
|
|
if( c->readBoolEntry( "manual settings", false ) ) {
|
|
|
|
|
int sr = c->readNumEntry( "samplerate", 44100 );
|
|
|
|
|
int ch = c->readNumEntry( "channels", 2 );
|
|
|
|
|
int wsize = c->readNumEntry( "data size", 16 );
|
|
|
|
|
TDEConfig* c = k3bcore->config();
|
|
|
|
|
c->setGroup( "K3bSoxEncoderPlugin" );
|
|
|
|
|
if( c->readBoolEntry( "manual settings", false ) ) {
|
|
|
|
|
int sr = c->readNumEntry( "samplerate", 44100 );
|
|
|
|
|
int ch = c->readNumEntry( "channels", 2 );
|
|
|
|
|
int wsize = c->readNumEntry( "data size", 16 );
|
|
|
|
|
|
|
|
|
|
return msf.totalFrames()*sr*ch*wsize/75;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// fallback to raw
|
|
|
|
|
return msf.audioBytes();
|
|
|
|
|
}
|
|
|
|
|
return msf.totalFrames()*sr*ch*wsize/75;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// fallback to raw
|
|
|
|
|
return msf.audioBytes();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
K3bPluginConfigWidget* K3bSoxEncoder::createConfigWidget( TQWidget* parent,
|
|
|
|
|
const char* name ) const
|
|
|
|
|
const char* name ) const
|
|
|
|
|
{
|
|
|
|
|
return new K3bSoxEncoderSettingsWidget( parent, name );
|
|
|
|
|
}
|
|
|
|
@ -435,16 +435,16 @@ void K3bSoxEncoderSettingsWidget::saveConfig()
|
|
|
|
|
c->writeEntry( "manual settings", w->m_checkManual->isChecked() );
|
|
|
|
|
|
|
|
|
|
c->writeEntry( "channels", w->m_comboChannels->currentItem() == 0
|
|
|
|
|
? 1
|
|
|
|
|
: ( w->m_comboChannels->currentItem() == 2
|
|
|
|
|
? 4
|
|
|
|
|
: 2 ) );
|
|
|
|
|
? 1
|
|
|
|
|
: ( w->m_comboChannels->currentItem() == 2
|
|
|
|
|
? 4
|
|
|
|
|
: 2 ) );
|
|
|
|
|
|
|
|
|
|
c->writeEntry( "data size", w->m_comboSize->currentItem() == 0
|
|
|
|
|
? 8
|
|
|
|
|
: ( w->m_comboSize->currentItem() == 2
|
|
|
|
|
? 32
|
|
|
|
|
: 16 ) );
|
|
|
|
|
? 8
|
|
|
|
|
: ( w->m_comboSize->currentItem() == 2
|
|
|
|
|
? 32
|
|
|
|
|
: 16 ) );
|
|
|
|
|
|
|
|
|
|
c->writeEntry( "samplerate", w->m_editSamplerate->text().toInt() );
|
|
|
|
|
|
|
|
|
|