Jump to content

BASS Function Library (Sound and Music Functions)


BrettF
 Share

Recommended Posts

From my basic understanding of the function.

_Bass_StreamCreateURL will:

Create a sample stream from an MP3, MP2, MP1, OGG, WAV, AIFF or plugin supported file on the internet, optionally receiving the downloaded data in a callback function.

Error 41 is $BASS_ERROR_FILEFORM - invalid file format. The stream has to be one of the above formats.

Cheers,

Brett

Link to comment
Share on other sites

From my basic understanding of the function.

_Bass_StreamCreateURL will:

Create a sample stream from an MP3, MP2, MP1, OGG, WAV, AIFF or plugin supported file on the internet, optionally receiving the downloaded data in a callback function.

Error 41 is $BASS_ERROR_FILEFORM - invalid file format. The stream has to be one of the above formats.

Cheers,

Brett

Its a Shoutcast stream in "Content-Type: audio/aacp"

I was hoping to use only BASS UDF to tune in and record the stream, may have to use Winamp or the new VLC UDF with BASS record function.

Thanks!

2015 - Still no flying cars, instead blankets with sleeves.

Link to comment
Share on other sites

OK, I'm an idiot. I can't figure this out. I'm trying to use BASSMix.Au3 to mix and stream a stereo file to the front left channel of a 5.1 system. Thanks to Brett and eukalyptus I have the wonderfull au3 but I can't figure out how to create the matrix. BTW, I'll want to do the same thing 5 more times with different mixings to the other 5.1 channels.

Here's my code:

#include <Bass.au3>
#include <BassMix.au3>
#Include <Array.au3>
Local $FLMatrix[1][2]
$FLMatrix[0][0] = 0.5
$FLMatrix[0][1] = -0.5 ;right side to be inverted
_BASS_Startup ()
_BASS_Init($BASS_DEVICE_SPEAKERS, -1, 44100, 0, "")
;Check if bass iniated.  If not, we cannot continue.
If @error Then
    MsgBox(0, "Error", "Could not initialize audio")
    Exit
EndIf
_BASS_MIX_Startup()
_BASS_SetConfig($BASS_CONFIG_MIXER_BUFFER, 5)

$channel1 = _BASS_StreamCreateFile(False, @ScriptDir & "\Stereo.wav", 0, 0, $BASS_STREAM_DECODE)

$StereoStream1 = _BASS_Mixer_StreamCreate(44100, 2, $BASS_STREAM_DECODE)


$StreamMatrix1 = _BASS_Mixer_ChannelSetMatrix($StereoStream1,$FLMatrix)

$MixChannel1 = _BASS_Mixer_StreamAddChannel($StereoStream1, $channel1, $StreamMatrix1)

$FrontLeft = _BASS_Mixer_ChannelGetMatrix($MixChannel1, $StreamMatrix1)

$FLOutPut = _BASS_StreamCreate(44100,1,$BASS_SPEAKER_FRONTLEFT,$FrontLeft,0)

_BASS_ChannelPlay($FLOutPut, 1)

While 1
    sleep(50)
Wend

It just makes a clicking sound out of the left front speaker. Any ideas?

Thanks,

Joe

Edited by a440hz

Are you experienced?

Link to comment
Share on other sites

I have ran most examples and I must say, this is damn cool :)

There is one particular example, the most interesting one, the recorder, which didn't want to run.

Quite a bit of errors aswell. I am using the latest AutoIt.

Thanks for alerting me to that. If you look in the first post you should see a section called patches. Please try "Patch 1" and get back to me to whether it works.

OK, I'm an idiot. I can't figure this out. I'm trying to use BASSMix.Au3 to mix and stream a stereo file to the front left channel of a 5.1 system. Thanks to Brett and eukalyptus I have the wonderfull au3 but I can't figure out how to create the matrix. BTW, I'll want to do the same thing 5 more times with different mixings to the other 5.1 channels.

Here's my code:

#include <Bass.au3>
#include <BassMix.au3>
#Include <Array.au3>
Local $FLMatrix[1][2]
$FLMatrix[0][0] = 0.5
$FLMatrix[0][1] = -0.5 ;right side to be inverted
_BASS_Startup ()
_BASS_Init($BASS_DEVICE_SPEAKERS, -1, 44100, 0, "")
;Check if bass iniated.  If not, we cannot continue.
If @error Then
    MsgBox(0, "Error", "Could not initialize audio")
    Exit
EndIf
_BASS_MIX_Startup()
_BASS_SetConfig($BASS_CONFIG_MIXER_BUFFER, 5)

$channel1 = _BASS_StreamCreateFile(False, @ScriptDir & "\Stereo.wav", 0, 0, $BASS_STREAM_DECODE)

$StereoStream1 = _BASS_Mixer_StreamCreate(44100, 2, $BASS_STREAM_DECODE)


$StreamMatrix1 = _BASS_Mixer_ChannelSetMatrix($StereoStream1,$FLMatrix)

$MixChannel1 = _BASS_Mixer_StreamAddChannel($StereoStream1, $channel1, $StreamMatrix1)

$FrontLeft = _BASS_Mixer_ChannelGetMatrix($MixChannel1, $StreamMatrix1)

$FLOutPut = _BASS_StreamCreate(44100,1,$BASS_SPEAKER_FRONTLEFT,$FrontLeft,0)

_BASS_ChannelPlay($FLOutPut, 1)

While 1
    sleep(50)
Wend

It just makes a clicking sound out of the left front speaker. Any ideas?

Thanks,

Joe

Hi Joe,

As I'm at uni now I can't test until I get home, and that means I have got to make my rig 5.1 again. The joys of being lazy... :(

In the meantime I'll try some things out and see if I can isolate the issue. It might be easier if you add me on msn too (check my profile) so I can just give you stuff to check a lot quicker. If do have it and add me, just tell me your username that you are from AutoIt so I know its you. I block around 2-3 requests a week, so yeah... :idea:

Cheers,

Brett

Link to comment
Share on other sites

Joe,

Give this a go. No idea if it works, but it worked for me (on my laptops 2ch, I will test the 5.1 later).

#include <Bass.au3>
#include <BassMix.au3>
#include <Array.au3>
#include <Math.au3>

OnAutoItExitRegister("ExitFunctions")
;Front Left / Front Right
$CHK_SPKR_0 = 1
;Speaker Set 1
$CHK_SPKR_1 = 1
;Speaker Set 2
$CHK_SPKR_2 = 1
;Speaker Set 3
$CHK_SPKR_3 = 1

_BASS_Startup()
_BASS_MIX_Startup()

_BASS_Init($BASS_DEVICE_SPEAKERS, -1, 44100, 0, "")
;Check if bass iniated.  If not, we cannot continue.
If @error Then
    MsgBox(0, "Error", "Could not initialize audio")
    Exit
EndIf

_BASS_SetConfig($BASS_CONFIG_MIXER_BUFFER, 5)

$source = _BASS_StreamCreateFile(False, @ScriptDir & "\Stereo.mp3", 0, 0, $BASS_STREAM_DECODE + $BASS_SAMPLE_FLOAT + $BASS_SAMPLE_LOOP)

$si = _BASS_ChannelGetInfo($source)
$di = _BASS_GetInfo()

$mixer = _BASS_Mixer_StreamCreate($si[0], _Min($di[12], 8), 0)

$MixChannel1 = _BASS_Mixer_StreamAddChannel($mixer, $source, $BASS_MIXER_MATRIX)

SetMatrix()

_BASS_ChannelPlay($mixer, False)

While 1
    Sleep(50)
WEnd

Func SetMatrix()
    Local $si = _BASS_ChannelGetInfo($source)
    Local $mi = _BASS_ChannelGetInfo($mixer)
    Local $matrix[$mi[1] * $si[1]]
    If ($CHK_SPKR_0 = 1) Then ; 1st pair of speakers enabled
        $matrix[0 * $si[1] + 0] = 1
        If ($si[1] = 1) Then ; mono source
            $matrix[1 * $si[1] + 0] = 1
        Else
            $matrix[1 * $si[1] + 1] = 1
        EndIf
    EndIf
    If ($mi[1] >= 4 And $CHK_SPKR_1 = 1) Then ; 2nd pair of speakers enabled
        If ($si[1] > 2) Then ; multi-channel source
            $matrix[2 * $si[1] + 2] = 1
            If ($si[1] > 3) Then $matrix[3 * $si[1] + 3] = 1
        Else
            $matrix[2 * $si[1] + 0] = 1
            If ($si[1] = 1) Then ; mono source
                $matrix[3 * $si[1] + 0] = 1
            Else ; stereo source
                $matrix[3 * $si[1] + 1] = 1
            EndIf
        EndIf
    EndIf
    If ($mi[1] >= 6 And $CHK_SPKR_2 = 1) Then ; 3rd pair of speakers enabled
        If ($si[1] > 2) Then ; multi-channel source
            If ($si[1] > 4) Then $matrix[4 * $si[1] + 4] = 1
            If ($si[1] > 5) Then $matrix[5 * $si[1] + 5] = 1
        Else
            $matrix[4 * $si[1] + 0] = 1
            If ($si[1] = 1) Then ; mono source
                $matrix[5 * $si[1] + 0] = 1
            Else ; stereo source
                $matrix[5 * $si[1] + 1] = 1
            EndIf
        EndIf
    EndIf
    If ($mi[1] >= 8 And $CHK_SPKR_3 = 1) Then ; 4th pair of speakers enabled
        If ($si[1] > 2) Then ; multi-channel source
            If ($si[1] > 6) Then $matrix[6 * $si[1] + 6] = 1
            If ($si[1] > 7) Then $matrix[7 * $si[1] + 7] = 1
        Else
            $matrix[6 * $si[1] + 0] = 1
            If ($si[1] = 1) Then ; mono source
                $matrix[7 * $si[1] + 0] = 1
            Else ; stereo source
                $matrix[7 * $si[1] + 1] = 1
            EndIf
        EndIf
    EndIf
    $mstruct = DllStructCreate("float[" & UBound($matrix) - 1 & "];")

    For $i = 0 To UBound($matrix) - 1
        DllStructSetData($mstruct, 1, $matrix[$i], $i+1)
    Next
    $StreamMatrix1 = _BASS_Mixer_ChannelSetMatrix($source, DllStructGetPtr($mstruct))
EndFunc   ;==>SetMatrix

Func ExitFunctions ()
    _Bass_Stop()
    _BASS_Free()
EndFunc

Cheers,

Brett

Link to comment
Share on other sites

Thanks Brett, I appreciate your help! :idea:

I will try your script when I get home from work.

I was looking at the bass website and an example of how to use the matrix not really related to what I'm trying to do and I came up with this modification to my code. I haven't tried it yet. Of course I can't wait to get home and try both.

#include <Bass.au3>
#include <BassMix.au3>
#Include <Array.au3>
Local $FLMatrix[1][2]

_BASS_Startup ()
_BASS_Init($BASS_DEVICE_SPEAKERS, -1, 44100, 0, "")
;Check if bass iniated.  If not, we cannot continue.
If @error Then
    MsgBox(0, "Error", "Could not initialize audio")
    Exit
EndIf
;start up the mixer?
_BASS_MIX_Startup()
;set a large buffer (maybe tto large but I may have very large wavs)
_BASS_SetConfig($BASS_CONFIG_MIXER_BUFFER, 5)
;open the stereo file
$channel1 = _BASS_StreamCreateFile(False, @ScriptDir & "\Stereo.wav", 0, 0, $BASS_STREAM_DECODE)
;create a stereo mixer
$MixerStream1 = _BASS_Mixer_StreamCreate(44100, 2, $BASS_STREAM_DECODE)
;add it the the matrix
_BASS_Mixer_StreamAddChannel($StereoStream1, $channel1, $BASS_MIXER_MATRIX)
;create the matrix
$FLMatrix[0][0] = 0.5
$FLMatrix[0][1] = -0.5
;apply the matrix
$StreamMatrix1 = _BASS_Mixer_ChannelSetMatrix($StereoStream1,$FLMatrix)
;assign the output to front left speaker
$FLOutPut = _BASS_StreamCreate(44100,1,$BASS_SPEAKER_FRONTLEFT,$MixerStream1,0)
;play the mixed file
_BASS_ChannelPlay($FLOutPut, 1)

While 1
    sleep(50)
Wend

All the Best,

Joe

Are you experienced?

Link to comment
Share on other sites

Try with whole values first :idea:

Let me know how it goes. I'll be working tomorrow/today so expect a delayed response.

Cheers,

Brett

Edited by BrettF
Link to comment
Share on other sites

Hi Brett,

Please forgive my very limited programming knowledge, I never learned C and always used VBA, VB or VBScript until I discovered AutoIt. Three cheers for all the contributors to this fantastic project!!

My code does not work at all.

Yours plays but though all speakers. I'm very interested in how you created the matrix with DllStructCreate as that appears to be how BASS needs the floating point array fed to it.

My script's needs are much more specific than your script assumes (though I certainly appreciate your effort to help!) :idea:

1. It will always be using a stereo source file (though I do appreciate the ability to varies the bit depth,sample rate and filetype)

2. It will always be using the following matrix (as explained by Ian at Un4seen and presented here as C code)

float matrix[1][2]={

{0.5, -0.5},

};

The two values will vary but will always be less than 1 and will be a mix of positive and negative gains of either side of the same stereo source file.

3. It will always be playing back through a 6 channel speaker setup BUT will always create 6 separate streams calculated independently and specifically assigned to one of the 5.1 speakers.

Will you have the time to explain to me how to create a DllStructure and set the data as in the above example so I can create a single stream and use the same method to create the remaining 5? With the other help you've given me I should hope to be able to proceed.

I would like to thank you again for all your work bringing BASS to AutoIt!!

Don't work too hard,

Joe

Edited by a440hz

Are you experienced?

Link to comment
Share on other sites

Yes, definitely!

Thanks to you, here's what I've got so far but it still doesn't work. For this example I only want to output to the front left speaker for a test. I think I just need to know how to structure the two dimensional float array.

Thanks,

Joe

#include <Bass.au3>
#include <BassMix.au3>
;do I need these next two?
#include <Array.au3>
#include <Math.au3>
Global $left, $right
OnAutoItExitRegister("ExitFunctions")
_BASS_Startup()
_BASS_MIX_Startup()

_BASS_Init($BASS_DEVICE_SPEAKERS, -1, 44100, 0, "")
;Check if bass iniated.  If not, we cannot continue.
If @error Then
    MsgBox(0, "Error", "Could not initialize audio")
    Exit
EndIf

_BASS_SetConfig($BASS_CONFIG_MIXER_BUFFER, 5)

$source = _BASS_StreamCreateFile(False, @ScriptDir & "\Stereo.wav", 0, 0, $BASS_STREAM_DECODE + $BASS_SAMPLE_FLOAT + $BASS_SAMPLE_LOOP)

$si = _BASS_ChannelGetInfo($source)
;check for stereo input
If $si[1] <> 2 Then
    MsgBox(0,"Error","This is not a stereo file!")
    Exit
EndIf

$di = _BASS_GetInfo()
;check for 5.1 audio support
If $di[12] < 8 Then
    MsgBox(0,"Error","It appears you do not have a 5.1 or higher system!")
    Exit
EndIf

$mixer1 = _BASS_Mixer_StreamCreate($si[0], $si[1], $BASS_SPEAKER_FRONTLEFT)

$MixChannel1 = _BASS_Mixer_StreamAddChannel($mixer1, $source, $BASS_MIXER_MATRIX)

SetMatrix(0.5,-0.5)

_BASS_ChannelPlay($mixer1, False)

While 1
    Sleep(50)
WEnd

Func SetMatrix($left, $right)
    Local $matrix[2][3]
    $matrix[1][1] = $left
    $matrix[1][2] = $right
    local $mstruct = DllStructCreate("float;float")

    DllStructSetData($mstruct, 1, $matrix[1][1])
    DllStructSetData($mstruct, 2, $matrix[1][2])
    _BASS_Mixer_ChannelSetMatrix($source, DllStructGetPtr($mstruct))
EndFunc   ;==>SetMatrix

Func ExitFunctions ()
    _BASS_Stop()
    _BASS_Free()
EndFunc
Edited by a440hz

Are you experienced?

Link to comment
Share on other sites

Brett,

I think all I need to do is figure out how to convert this to AutoIt.

float matrix[1][2]={

{0.5, -0.5}, // mono out = left - right in

};

BASS_Mixer_ChannelSetMatrix(source1, matrix); // apply the matrix

BASS_ChannePlay(mixer, FALSE); // play the mix

The last two lines I have but it's that float I can't figure out even from your example or from the AutoIt documentation.

Are you experienced?

Link to comment
Share on other sites

Can't see why this wouldn't work. Again only tested on my laptop which is 2ch, and they worked fine for me.

#include <Bass.au3>
#include <BassMix.au3>

OnAutoItExitRegister("ExitFunctions")

;Soundfiles can be found in Bass Examples - Multi Channel Viewer
$file1 = @ScriptDir & "\SoundFiles\FLeft.wav"
$file2 = @ScriptDir & "\SoundFiles\FCenter.wav"
$file3 = @ScriptDir & "\SoundFiles\FRight.wav"
$file4 = @ScriptDir & "\SoundFiles\RLeft.wav"
$file5 = @ScriptDir & "\SoundFiles\RRight.wav"

;Start both
_BASS_Startup()
ConsoleWrite ("Starting up Bass: " & @error & @CRLF)
_BASS_MIX_Startup()
ConsoleWrite ("Starting up Bass Mix: " & @error & @CRLF)

;Init Bass functions
_BASS_Init($BASS_DEVICE_SPEAKERS, -1, 44100, 0, "")
ConsoleWrite (@CRLF & "Init Bass: " & @error & @CRLF)
;Check if bass iniated.  If not, we cannot continue.
If @error Then
    MsgBox(0, "Error", "Could not initialize audio")
    Exit
EndIf

ConsoleWrite (@CRLF & "Start Creating Source Streams" & @CRLF)
$src_channel_1 = _BASS_StreamCreateFile(False, $file1, 0, 0, $BASS_SAMPLE_MONO + $BASS_SAMPLE_LOOP + $BASS_STREAM_DECODE)
ConsoleWrite ("Front Left: " & @error & @CRLF)
$src_channel_2 = _BASS_StreamCreateFile(False, $file2, 0, 0, $BASS_SAMPLE_MONO + $BASS_SAMPLE_LOOP + $BASS_STREAM_DECODE)
ConsoleWrite ("Front Center: " & @error & @CRLF)
$src_channel_3 = _BASS_StreamCreateFile(False, $file3, 0, 0, $BASS_SAMPLE_MONO + $BASS_SAMPLE_LOOP + $BASS_STREAM_DECODE)
ConsoleWrite ("Front Right: " & @error & @CRLF)
$src_channel_4 = _BASS_StreamCreateFile(False, $file4, 0, 0, $BASS_SAMPLE_MONO + $BASS_SAMPLE_LOOP + $BASS_STREAM_DECODE)
ConsoleWrite ("Rear Left: " & @error & @CRLF)
$src_channel_5 = _BASS_StreamCreateFile(False, $file5, 0, 0, $BASS_SAMPLE_MONO + $BASS_SAMPLE_LOOP + $BASS_STREAM_DECODE)
ConsoleWrite ("Rear Right: " & @error & @CRLF)

ConsoleWrite (@CRLF & "Start Creating Mixer Streams" & @CRLF)
$out_chan_1 = _BASS_Split_StreamCreate($src_channel_1, $BASS_SPEAKER_FRONTLEFT, 0)
ConsoleWrite ("Front Left: " & @error & @CRLF)
$out_chan_2 = _BASS_Split_StreamCreate($src_channel_2, $BASS_SPEAKER_CENTER, 0)
ConsoleWrite ("Front Center: " & @error & @CRLF)
$out_chan_3 = _BASS_Split_StreamCreate($src_channel_3, $BASS_SPEAKER_FRONTRIGHT, 0)
ConsoleWrite ("Front Right: " & @error & @CRLF)
$out_chan_4 = _BASS_Split_StreamCreate($src_channel_4, $BASS_SPEAKER_REARLEFT, 0)
ConsoleWrite ("Rear Left: " & @error & @CRLF)
$out_chan_5 = _BASS_Split_StreamCreate($src_channel_5, $BASS_SPEAKER_REARRIGHT, 0)
ConsoleWrite ("Rear Right: " & @error & @CRLF)

ConsoleWrite (@CRLF & "Start Linking Channels" & @CRLF)
_BASS_ChannelSetLink($out_chan_1, $out_chan_2)
ConsoleWrite ("Front Left & Front Center: " & @error & @CRLF)
_BASS_ChannelSetLink($out_chan_1, $out_chan_3)
ConsoleWrite ("Front Left & Front Right: " & @error & @CRLF)
_BASS_ChannelSetLink($out_chan_1, $out_chan_4)
ConsoleWrite ("Front Left & Rear Left: " & @error & @CRLF)
_BASS_ChannelSetLink($out_chan_1, $out_chan_5)
ConsoleWrite ("Front Left & Rear Right: " & @error & @CRLF)

ConsoleWrite (@CRLF & "Start Playing Channel 1 which should play all channels if linking was successful" & @CRLF)
_BASS_ChannelPlay($out_chan_1, False)

While 1
    Sleep(50)
WEnd

Func ExitFunctions ()
    _Bass_Stop()
    _BASS_Free()
EndFunc

Let me know how it goes :idea:

Link to comment
Share on other sites

Hi guys,

I'm not sure whether I'm being clear about what I need here. I thought I was but I'll give it another try.

I need to take a single stereo file and mix it in 6 different combinations, assigning each mix one of the 6 channels in a 5.1 setup.

Thanks to your help with in the past I have no problem creating the mixed mono files and using Bass.au3 to play them back in 5.1.

The reason I requested BassMix.au3 (thanks gain E) was that I researched and that appeared to be the only way I could accomplish my goal which, simply stated is to create a surround upmix out of a stereo source file without the need to create the 6 mono files. All I care about right now is getting a result to come out of the front left speaker after that works I'll have no problem with the other channels. I'm sorry I can't give out all the formula as it isn't mine to share but I think if I could get this one 2 dimension float into my last example it would work.

Below is a copy of a conversation on the Bass forum with Ian regarding this goal that is the reason I believe this and at the end you'll find my current attempt at taking what Brett has helped with and combining it with what I want to just play on the single speaker for now. Here is a link to my request and subsequent attempt after advice from UEZ.

Thank you so much!

All the best,

Joe

--------------------------------------------------------------------------------

A440hz

Hi,

Love Bass! I use it to playback 6 mono files into a 5.1 surround channel assignment.

I don't know anything about BASSMix. Using it and BASS, would it be possible to take a single stereo file and mix it to 6 independent mono streams that could then be assigned to a 5.1 layout? I'd need to invert the phase differently on either channel in all stereo to mono mixes. Ideally, I would like to do this all in a buffer and on multiple files from a playlist.

Thanks,

Joe

Ian @ un4seen

Do you just want to rearrange/invert the 6 channels? If so, BASSmix's matrix mixing feature could be used for that. If you want to actually split a 6 channel source into 6 separate streams, then BASSmix's "splitter" feature could be used to do that. Please see the BASSmix documentation for details on both.

A440hz

Thanks Ian!

I want to invert one of the stereo channels in different percentages. Am I right in assuming the following would work?

HSTREAM mixer=BASS_Mixer_StreamCreate(44100, 2, 0); // create a stereo mixer

HSTREAM source1=BASS_StreamCreateFile(FALSE, file1, 0, 0, BASS_STREAM_DECODE); // open 1st source file

BASS_Mixer_StreamAddChannel(mixer, source1, BASS_MIXER_MATRIX); // add it to the mix with matrix mixing enabled

float matrix[1][2]={

{0.5, -0.5}, // mono out = left - right in

};

BASS_Mixer_ChannelSetMatrix(source1, matrix); // apply the matrix

HSTREAM LFMIX=BASS_StreamCreate(44100,1,$BASS_SPEAKER_FRONTLEFT,mixer,0) // assign the mix to front left speaker

BASS_ChannePlay(LFMIX, FALSE); // play the mix

Thanks,

Joe

Ian @ un4seen

The matrix looks fine, but the "LFMIX" stream stuff not so much. I'm not sure there is really any need for that, as you could set the BASS_SPEAKER_FRONTLEFT flag on the mixer itself and make it mono. The code could be modified to look like this...

HSTREAM mixer=BASS_Mixer_StreamCreate(44100, 1, BASS_SPEAKER_FRONTLEFT); // create a mono mixer on front left speaker

HSTREAM source1=BASS_StreamCreateFile(FALSE, file1, 0, 0, BASS_STREAM_DECODE); // open 1st source file

BASS_Mixer_StreamAddChannel(mixer, source1, BASS_MIXER_MATRIX); // add it to the mix with matrix mixing enabled

float matrix[1][2]={

{0.5, -0.5}, // mono out = left - right in

};

BASS_Mixer_ChannelSetMatrix(source1, matrix); // apply the matrix

BASS_ChannePlay(mixer, FALSE); // play the mix

A440hz

Thanks Ian! I'll test when I get home from work

#include <Bass.au3>
#include <BassMix.au3>
#include <Array.au3>
#include <Math.au3>
Global $left, $right
OnAutoItExitRegister("ExitFunctions")
_BASS_Startup()
_BASS_MIX_Startup()

_BASS_Init($BASS_DEVICE_SPEAKERS, -1, 44100, 0, "")
;Check if bass iniated.  If not, we cannot continue.
If @error Then
    MsgBox(0, "Error", "Could not initialize audio")
    Exit
EndIf

_BASS_SetConfig($BASS_CONFIG_MIXER_BUFFER, 5)

$source = _BASS_StreamCreateFile(False, @ScriptDir & "\Stereo.wav", 0, 0, $BASS_STREAM_DECODE + $BASS_SAMPLE_FLOAT + $BASS_SAMPLE_LOOP)

$si = _BASS_ChannelGetInfo($source)
;check for stereo input
If $si[1] <> 2 Then
    MsgBox(0,"Error","This is not a stereo file!")
    Exit
EndIf

$di = _BASS_GetInfo()
;check for 5.1 audio support
If $di[12] < 8 Then
    MsgBox(0,"Error","It appears you do not have a 5.1 or higher system!")
    Exit
EndIf

$mixer1 = _BASS_Mixer_StreamCreate($si[0], $si[1], $BASS_SPEAKER_FRONTLEFT)

$MixChannel1 = _BASS_Mixer_StreamAddChannel($mixer1, $source, $BASS_MIXER_MATRIX)

SetMatrix(0.5,-0.5)

_BASS_ChannelPlay($mixer1, False)

While 1
    Sleep(50)
WEnd

;~ Func SetMatrix($left, $right)
;~  Local $matrix[2][3]
;~  $matrix[1][1] = $left
;~  $matrix[1][2] = $right
;~  local $mstruct = DllStructCreate("float[2]")

;~  DllStructSetData($mstruct, 1, $matrix[1][1],1)
;~  DllStructSetData($mstruct, 1, $matrix[1][2],2)
;~  $StreamMatrix1 = _BASS_Mixer_ChannelSetMatrix($source, DllStructGetPtr($mstruct))
;~ EndFunc   ;==>SetMatrix


;As suggested by UEZ
Func SetMatrix($left, $right)
    local $mstruct = DllStructCreate("float;float")
    DllStructSetData($mstruct, 1, $left)
    DllStructSetData($mstruct, 2, $right)
    $StreamMatrix1 = _BASS_Mixer_ChannelSetMatrix($source, DllStructGetPtr($mstruct))
EndFunc ;==>SetMatrix

Func ExitFunctions ()
    _BASS_Stop()
    _BASS_Free()
EndFunc
Edited by a440hz

Are you experienced?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...