Author Topic: [VB6] Writing a Bassmix stream to wave  (Read 2229 times)

Reinder[NL]

  • Guest
[VB6] Writing a Bassmix stream to wave
« on: 17 Feb '07 - 23:58 »
Hi there,

I'm making an application (in Visual Basic 6) that can mix some audiofiles, using Bassmix. Now I'd like to save this mix to a wave (or even better a mp3) file. But I can't figure out how to do that. I've looked at the WriteWav example, but that didn't help me... I've followed the example but I guess I did something wrong. It creates files of nearly 3 gigabyte, that just can't be the right. ::)

So is there anyone who can tell me how to save a Bassmix stream to wave? ???

Ian @ un4seen

  • Administrator
  • Posts: 20401
Re: [VB6] Writing a Bassmix stream to wave
« Reply #1 on: 18 Feb '07 - 16:05 »
I'd suggest using BASSenc... use the BASS_STREAM_DECODE flag (and BASS_MIXER_END) when creating the mixer, call BASS_Encode_Start (see docs for details) to set an encoder on the mixer, and then repeatedly call BASS_ChannelGetData to process the data until you reach the end. Something like this...

Code: [Select]
mixer=BASS_Mixer_StreamCreate(freq, chans, BASS_MIXER_END|BASS_STREAM_DECODE); // create mixer
// add mixer sources here
BASS_Encode_Start(mixer, "lame - output.mp3", BASS_ENCODE_AUTOFREE, 0, 0); // setup MP3 encoder (lame) on mixer
while (BASS_ChannelIsActive(mixer) && BASS_Encode_IsActive(mixer)) { // mixer and encoder still going...
BYTE buffer[20000]; // mixer rendering buffer
BASS_ChannelGetData(mixer, temp, sizeof(buffer)); // render and encode mixer output
}
BASS_StreamFree(mixer); // free mixer and encoder

Reinder[NL]

  • Guest
Re: [VB6] Writing a Bassmix stream to wave
« Reply #2 on: 18 Feb '07 - 20:10 »
Tnx very much. It works! ;D