Author Topic: BASS.Net - Recording multiple icecast at the same time  (Read 517 times)


  • Posts: 12
Hi, I'm trying to record 100 icecast streaming from a local server but after the recording start some of them just stop recording(file does not change size) but the connection still persist(endsync is never triggered). After sometime all of them stop recording with no disconnect.
Following is my code:

//inside main function
if (stations.Count > 0)

        Bass.BASS_Init(-1, 11025, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
        _mySync = new SYNCPROC(EndSync);

        foreach(KeyValuePair<int, Station> station in stations)
            RecordStreaming(station.Key, station.Value);


private static void RecordStreaming(int idStation, Station station)
        int stream = 0;

            stream = Bass.BASS_StreamCreateURL(station.Broadcast, 0,
                                  BASSFlag.BASS_SAMPLE_MONO | BASSFlag.BASS_STREAM_AUTOFREE | BASSFlag.BASS_STREAM_BLOCK, null, (IntPtr)idStation);

        Bass.BASS_ChannelSetSync(stream, BASSSync.BASS_SYNC_END, 0, _mySync, (IntPtr)idStation);
        EncoderLAME lame = new EncoderLAME(stream)
            OutputFile = idStation + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".mp3",
            LAME_Bitrate = (int)EncoderLAME.BITRATE.kbps_32,
            LAME_TargetSampleRate = (int)EncoderLAME.SAMPLERATE.Hz_11025,
            LAME_Mode = EncoderLAME.LAMEMode.Mono

        lame.Start(null, (IntPtr)idStation, false);
        Bass.BASS_ChannelPlay(stream, false);
        Bass.BASS_ChannelSetAttribute(stream, BASSAttribute.BASS_ATTRIB_VOL, 0);

 //end os stream callback
        private static void EndSync(int handle, int channel, int data, IntPtr user)
            int n = (int)user;
            RecordStreaming(n, stations[n]);

I don't know why the recording stop(no file change) and the connection doesn't end. Someone may help?


  • Posts: 12
I think the problem is related with the lame encoder. I can record up to 48 stations with no problem(each one with a lame.exe instance), more than that many lame.exe instances close. Someone knows about this limitation?


  • Posts: 12
I have solved the problem by replacing the EncodeLAME for the command line version:

BassEnc.BASS_Encode_Start(stream, "lame --priority 4 -m m --preset standard - "+ idStation + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".mp3", BASSEncode.BASS_ENCODE_AUTOFREE,null, (IntPtr)idStation);

Ian @ un4seen

  • Administrator
  • Posts: 21600
Good to hear that you found a solution.

I was about to suggest that, depending on your requirements, you could perhaps just save the downloaded data (via a DOWNLOADPROC callback) rather then re-encoding it with LAME.


  • Posts: 4643
Sounds a bit strange, as the EncoderLAME class also just only calls the command-line verison.
So I assume, that the real trouble shooter was, that your now used the "--priority 4" option; which you also could have been used with the EncoderLAME class....