18 Jun '13 - 23:34 *
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: Multichannel playback, one channel only -vb.net  (Read 341 times)
ward574
Guest
« on: 7 Sep '12 - 15:37 »
Reply with quoteQuote

Hi..

I have a multichannel .wav file (that has up to 16 audio channels) and I want to play back just 1 of those channels to speaker, but none of the others.


This is my code for playing a file: it plays every channel mixed together. How do I separate the audio channels to play just the one I want?


If Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero) Then

            ' create a stream channel from a file
            Dim stream As Integer = Bass.BASS_StreamCreateFile("Calibration_1_1.wav", 0, 0, BASSFlag.BASS_DEFAULT)
           
            If stream <> 0 Then
                ' play the stream channel
                Bass.BASS_ChannelPlay(stream, False)
            Else
                ' error creating the stream
                Console.WriteLine("Stream error: {0}", Bass.BASS_ErrorGetCode())
            End If

        End If



Thanks for any help..

*goes back to searching*
Logged
Ian @ un4seen
Administrator
Posts: 15363


« Reply #1 on: 7 Sep '12 - 17:22 »
Reply with quoteQuote

The simplest way to do that is with the BASSmix add-on's "splitter stream" feature, which allows you to extract specific channels. For example, something like this...

source=BASS_StreamCreateFile(FALSE, filename, 0, 0, BASS_STREAM_DECODE); // create a decoder for the audio file
int chanmap[2]={channelindex, -1}; // channel map to extract the wanted channel
split=BASS_Split_StreamCreate(source, 0, chanmap); // create a splitter stream using the decoder and channel map
BASS_ChannelPlay(split, FALSE); // start it

Please see the BASS_Split_StreamCreate documentation for details.
Logged
Ward574
Guest
« Reply #2 on: 10 Sep '12 - 09:11 »
Reply with quoteQuote

Brilliant, thanks.


I'll get onto tracking the audio playback position, threading, etc.
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines