From 9d5c687bbd84d14ab6d2486bffa61d6228eeb0ee Mon Sep 17 00:00:00 2001 From: darkeye Date: Fri, 19 Oct 2001 09:03:39 +0000 Subject: [PATCH] added support for resampling mp3 streams --- darkice/trunk/ChangeLog | 1 + darkice/trunk/TODO | 1 - darkice/trunk/man/darkice.cfg.5 | 16 +++++++++++++--- darkice/trunk/src/DarkIce.cpp | 13 +++++++++++-- darkice/trunk/src/LameLibEncoder.h | 8 +++----- 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/darkice/trunk/ChangeLog b/darkice/trunk/ChangeLog index a1a3fa2..3059b3f 100644 --- a/darkice/trunk/ChangeLog +++ b/darkice/trunk/ChangeLog @@ -2,6 +2,7 @@ DarkIce 0.7 o added support for FreeBSD thanks to Robin P. Blanchard, + o added support for resampling mp3 streams 18-09-2001: DarkIce 0.6 released diff --git a/darkice/trunk/TODO b/darkice/trunk/TODO index 03c57f9..6bf45fe 100644 --- a/darkice/trunk/TODO +++ b/darkice/trunk/TODO @@ -8,4 +8,3 @@ o revisit real-time scheduling and one-thread-per-connection o look into performance o create proper error-reporting module o enable TABs in the config file -o add support for downsampling the input for a given output diff --git a/darkice/trunk/man/darkice.cfg.5 b/darkice/trunk/man/darkice.cfg.5 index b153376..af50415 100644 --- a/darkice/trunk/man/darkice.cfg.5 +++ b/darkice/trunk/man/darkice.cfg.5 @@ -108,6 +108,10 @@ Mount point for the stream on the server .PP Optional values: +.TP +.I sampleRate +The sample rate of the encoded mp3 output. If not specified, defaults +to the value of the input sample rate. .TP .I name Name of the stream @@ -225,6 +229,10 @@ server .PP Optional values: +.TP +.I sampleRate +The sample rate of the encoded mp3 output. If not specified, defaults +to the value of the input sample rate. .TP .I name Name of the stream @@ -260,7 +268,7 @@ A sample configuration file follows. This file makes .B DarkIce stream for 1 minute (60 seconds) from the audio device .I /dev/dsp -at 22kHz, 16 bit stereo. +at 22.05kHz, 16 bit stereo. It will build up a connection to the .B IceCast server yp.yourserver.com on port 8000 with the password "hackme". @@ -304,13 +312,14 @@ A bit more complicated sample follows. This one makes .B DarkIce stream for 1 hour (3600 seconds) from the audio device .I /dev/dsp -at 22kHz, 16 bit stereo. +at 44.1kHz, 16 bit stereo. It will build up a connection to an .B IceCast server yp.your-ice-server.com on port 8000 with the password "ice-hackme". The sound for this stream will be cut at 10500 Hz from above. -The stream will be encoded to 96 kb/s mp3, and will be reachable at +The stream will be encoded to 96 kb/s mp3 and resampled to 22.05kHz. +The stream will be reachable at .I http://yp.your-ice-server.com:8000/live96 to mp3 players. The encoding session will be stored by @@ -338,6 +347,7 @@ bitsPerSample = 16 channel = 2 [icecast-0] +sampleRate = 22050 bitrate = 96 lowpass = 10500 server = yp.your-ice-server.com diff --git a/darkice/trunk/src/DarkIce.cpp b/darkice/trunk/src/DarkIce.cpp index 99eb6cc..489ace8 100644 --- a/darkice/trunk/src/DarkIce.cpp +++ b/darkice/trunk/src/DarkIce.cpp @@ -183,6 +183,7 @@ DarkIce :: configIceCast ( const Config & config, break; } + unsigned int sampleRate = 0; unsigned int bitrate = 0; const char * server = 0; unsigned int port = 0; @@ -197,6 +198,8 @@ DarkIce :: configIceCast ( const Config & config, unsigned int lowpass = 0; unsigned int highpass = 0; + str = cs->get( "sampleRate"); + sampleRate = str ? Util::strToL( str) : dsp->getSampleRate(); str = cs->getForSure("bitrate", " missing in section ", stream); bitrate = Util::strToL( str); server = cs->getForSure( "server", " missing in section ", stream); @@ -243,7 +246,7 @@ DarkIce :: configIceCast ( const Config & config, audioOuts[u].encoder = new LameLibEncoder( audioOuts[u].server.get(), dsp.get(), bitrate, - dsp->getSampleRate(), + sampleRate, dsp->getChannel(), lowpass, highpass ); @@ -366,6 +369,7 @@ DarkIce :: configShoutCast ( const Config & config, break; } + unsigned int sampleRate = 0; unsigned int bitrate = 0; const char * server = 0; unsigned int port = 0; @@ -380,6 +384,8 @@ DarkIce :: configShoutCast ( const Config & config, const char * aim = 0; const char * icq = 0; + str = cs->get( "sampleRate"); + sampleRate = str ? Util::strToL( str) : dsp->getSampleRate(); str = cs->getForSure("bitrate", " missing in section ", stream); bitrate = Util::strToL( str); server = cs->getForSure( "server", " missing in section ", stream); @@ -424,7 +430,7 @@ DarkIce :: configShoutCast ( const Config & config, audioOuts[u].encoder = new LameLibEncoder( audioOuts[u].server.get(), dsp.get(), bitrate, - dsp->getSampleRate(), + sampleRate, dsp->getChannel(), lowpass, highpass ); @@ -568,6 +574,9 @@ DarkIce :: run ( void ) throw ( Exception ) $Source$ $Log$ + Revision 1.20 2001/10/19 09:03:39 darkeye + added support for resampling mp3 streams + Revision 1.19 2001/09/14 19:31:06 darkeye added IceCast2 / vorbis support diff --git a/darkice/trunk/src/LameLibEncoder.h b/darkice/trunk/src/LameLibEncoder.h index 97c653d..17c7730 100644 --- a/darkice/trunk/src/LameLibEncoder.h +++ b/darkice/trunk/src/LameLibEncoder.h @@ -124,11 +124,6 @@ class LameLibEncoder : public AudioEncoder, public virtual Reporter getInBitsPerSample() ); } - if ( getOutSampleRate() != getInSampleRate() ) { - throw Exception( __FILE__, __LINE__, - "different in and out sample rate not supported"); - } - if ( getInChannel() != getOutChannel() ) { throw Exception( __FILE__, __LINE__, "different in and out channels not supported"); @@ -462,6 +457,9 @@ class LameLibEncoder : public AudioEncoder, public virtual Reporter $Source$ $Log$ + Revision 1.8 2001/10/19 09:03:39 darkeye + added support for resampling mp3 streams + Revision 1.7 2001/09/15 11:35:08 darkeye minor fixes