20 May '13 - 00:10 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Reply  |  Print  
Author Topic: Mixing multiple channels that use the same file  (Read 341 times)
elnels
Posts: 4


« on: 26 Apr '12 - 18:46 »
Reply with quoteQuote

I'm using Bass.Net 2.4.6.8 (I'm new) and have ran across a problem which is most likely my own.  I am mixing several channels which contain 1-2 second .ogg files (decoded).  They are offset at various times and have effects applied to them.  Often the channels originate from the same .ogg file, but are offset in time to create a looping effect.  The problem is when I apply different effects to different channels that originate from the same file, the first effect get's applied to all channels with the same file.  Here's my code:   

public void AddToMixer(int mixer, int mixerBpm)
{
      //Create effects channel
      var bassStream = Bass.BASS_StreamCreateFile(Path + FileName, 0, 0, BASSFlag.BASS_STREAM_DECODE);
      bassStream = BassFx.BASS_FX_TempoCreate(bassStream, BASSFlag.BASS_STREAM_DECODE);
           
      //setup effects
      Bass.BASS_ChannelSetAttribute(bassStream, BASSAttribute.BASS_ATTRIB_TEMPO, (float) Percentage);
      Bass.BASS_ChannelSetAttribute(bassStream, BASSAttribute.BASS_ATTRIB_PAN, (float)Pan);

      // delay channel (calculateStartTime retreives the seconds to delay by)
      var start = Bass.BASS_ChannelSeconds2Bytes(mixer, CalculateStartTime(mixerBpm));
      BassMix.BASS_Mixer_StreamAddChannelEx(mixer, bassStream, BASSFlag.BASS_STREAM_AUTOFREE, start, 0);
      Debug.WriteLine("Stream: " + bassStream + ", Song Id: " + Id + ", Pan: " + Pan);
}

Here's my output from the debug.writeLine:
Stream: -1342177277, Song Id: 177, Pan: -1
Stream: -1342177274, Song Id: 177, Pan: 0
Stream: -1342177271, Song Id: 177, Pan: 0
Stream: -1342177268, Song Id: 177, Pan: 0
Stream: -1342177265, Song Id: 177, Pan: 0
Stream: -1342177262, Song Id: 145, Pan: 0
Stream: -1342177259, Song Id: 145, Pan: 0

The problem is all Song Id's of 177 will have a Pan of -1 (left) when I view the final .ogg file in Audacity even though the rest should be centered at 0.  Any idea as to why this happens?
Logged
Ian @ un4seen
Administrator
Posts: 15244


« Reply #1 on: 27 Apr '12 - 14:27 »
Reply with quoteQuote

That's strange. The only thing that comes to mind is that the audio file (with id 177) is panned left itself, ie. it contains nothing on the right. What do you see if you load that file into Audacity? If that isn't it, what happens if you set the first instance's pan position to +1 instead of -1, eg. do they all move to the right then?

Btw, it looks like you may have a stream/memory leak with that code, as the stream created by BASS_StreamCreateFile doesn't appear to be getting freed. You can add the BASS_FX_FREESOURCE flag to your BASS_Tempo_StreamCreate call to have the source stream freed at the same time as the tempo stream is.
Logged
elnels
Posts: 4


« Reply #2 on: 30 Apr '12 - 18:43 »
Reply with quoteQuote

@Ian,
Well I feel like an idiot.  I looked at the audio file and it was indeed panned to the left.  Sorry for that.

Also, thanks for the memory leak tip.  I was wondering how to handle this as I was trying to use AutoFree flag prior but later found out that the Bass_Stream_Decode flag didn't work in conjunction with it.  I will be running a memory profile on this shortly to make sure everything is getting released appropriately.  Smiley

Thanks for all the help! 
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines