Author Topic: writing non decode mixer to wav produces wav of zero bytes.  (Read 319 times)

vandenbrakel

  • Posts: 17
We are trying to write the output of our main mixer (non decode stream) to disc by adding it to a new decoded mixer and put the encoder on that:
It produces the file but there's no data going into it.

Any idea what we are missing? Thanks.


C# code:
Code: [Select]
mixer = BassMix.CreateMixerStream(44100, 2, BassFlags.Decode | BassFlags.Float); // create stereo mixer with same sample rate
var state = BassMix.MixerAddChannel(mixer, BassMixer.Instance.MixerStream,BassFlags.Default);
encoder = BassEnc.EncodeStart(mixer, filename, EncodeFlags.PCM, null, IntPtr.Zero);

Best,

Sander

MB_SOFT

  • Posts: 270
In my opinion you should add the encoder directly to the playing main mixer

vandenbrakel

  • Posts: 17
In my opinion you should add the encoder directly to the playing main mixer

Is that possible if that's not a decode stream? (it crashes if I do that)

MB_SOFT

  • Posts: 270
yes, you can attach an encoder to any mixer,d ecoding or not.

try like this:

encoder = BassEnc.EncodeStart(BassMixer.Instance.MixerStream, filename, EncodeFlags.PCM, null, IntPtr.Zero);

and if your MixerSteram is float maybe you have to add the BASS_ENCODE_FP_16BIT flag to the encoder
 

vandenbrakel

  • Posts: 17
yes, you can attach an encoder to any mixer,d ecoding or not.

try like this:

encoder = BassEnc.EncodeStart(BassMixer.Instance.MixerStream, filename, EncodeFlags.PCM, null, IntPtr.Zero);

and if your MixerSteram is float maybe you have to add the BASS_ENCODE_FP_16BIT flag to the encoder

Ok, I assumed that was not possible as it crashes when I do that. I've created a console barebone app that reflects the mixer setup of our more complex normal setup. Maybe it helps:

Code: [Select]
Bass.Init(-1);

            var path = "/Users/me/Downloads/";


               var beatles = Bass.CreateStream(path + "beatles.mp3", 0, 0, BassFlags.Decode); ;
            Console.WriteLine(Bass.LastError);

            var mixer = BassMix.CreateMixerStream(44100, 2, BassFlags.Float); // create stereo mixer with same sample rate
            Console.WriteLine(Bass.LastError);

            var state = BassMix.MixerAddChannel(mixer, beatles, BassFlags.Default); // plug decoder into mixer with downmixing enabled
               BassMix.MixerAddChannel(mixer, beatles, BassFlags.Default | BassFlags.MixerBuffer | BassFlags.AutoFree);

            Console.WriteLine(Bass.LastError);
           var encoder = BassEnc.EncodeStart(mixer,  path + "output.wav", EncodeFlags.PCM | EncodeFlags.ConvertFloatTo16BitInt, null, IntPtr.Zero);

            Console.WriteLine(Bass.LastError);

            Bass.ChannelPlay(mixer);

Output:

OK
OK
Already
OK
Process is terminating due to StackOverflowException.

Press any key to continue...




If I comment out the encoder line it plays the mixer, no exception.


MB_SOFT

  • Posts: 270
wait for ian answer tomorrow ...probaly he will have a clue

vandenbrakel

  • Posts: 17
wait for ian answer tomorrow ...probaly he will have a clue

Hope so. Thanks for thinking with us.

Ian @ un4seen

  • Administrator
  • Posts: 21682
I'm not a .Net user myself, so I'm afraid I can't give a definitive answer or solution. Everything I can find about "StackOverflowException" says that it's caused by recursive calls but there don't seem to be any in your code above, so I guess it can also happen if the stack just gets too big. Does .Net allow you to set the stack size? If so, you could try increasing that.

Regarding the original question, as MB_SOFT says, you could set the encoder directly on the main mixer. You may also want to use the BASS_ENCODE_QUEUE flag in that case to avoid IO delays.