Jump to content

BASS Function Library (Sound and Music Functions)


BrettF
 Share

Recommended Posts

To use sox for lfe, just insert:

@ScriptDir & '\sox -s -b 16 -c 2 -r 44100 -t raw - -c 1 -t wav - Lowpass 120'

you are now official beta tester of the brand-new BassExt.dll :party:

Works great!!

I can see a lot of potential here.

Thanks again to you and to ProgAndy. :mellow::P

Are you experienced?

Link to comment
Share on other sites

@a440hz

I have created a testscript that uses CenterCut as encoder and plays the centercutted stream in (nearly) realtime.

http://rapidshare.com/files/396702597/CenterCut.zip.html

you can feed now every bass stream to centercut;

a stream from a file, or from the record-in, or a stream from an Url...

And you can use any other cmdline prog with stdin/out...

E

E,

I hear a quick pop when the song starts playing using your test script. I have an Creative X-Fi Music Extreme. I'll soon be test it with the additional 4 buffered BassMIx channels and the SoX generated LFE. I wonder ... will syncing the 6 channels be an issue?

I've already used your previous example to accomplish what I needed to do, though. :mellow:

I was able to play all six channels without writing a single wav file!!

But after reading ProgAndy's advice regarding StdoutRead being able to read binary I tried what I thought should work but didn't. I'm probably not doing it right. Here's the test script to compare $iSize :

#include "Bass.au3"
#include <Memory.au3>
#include <Constants.au3>


Global $hPid, $sStdout = "", $bStdout, $iSize
Global $hStream, $tStruct, $pStruct, $iPos


$hPid = Run("CenterCutCl stereo.wav -c stdout", @ScriptDir, @SW_SHOW, $STDOUT_CHILD)
While 1
    $sStdout &= StdoutRead($hPid)
    If @error Then ExitLoop
WEnd

$bStdout = StringToBinary($sStdout)
$iSize = BinaryLen($bStdout)
ConsoleWrite($iSize & @CRLF)


$hPid = Run("CenterCutCl stereo.wav -c stdout", @ScriptDir, @SW_SHOW, $STDOUT_CHILD)
While 1
    $sStdout &= StdoutRead($hPid,0,1)
    If @error Then ExitLoop
WEnd

$iSize = BinaryLen($sStdout)
ConsoleWrite($iSize & @CRLF)

Returns the following values on a short 16 sec wav

1462820

4388730

The first appears to be correct as it plays

I'd also be interested in using the method in your sample script to buffer instead of stream for the possibility of gapless playback but I'm not sure how I'd have to do it.

Thanks & all the best,

Joe

Are you experienced?

Link to comment
Share on other sites

You forgot to reset $sStdout for the second loop:

$sStdout = Binary("")
$hPid = Run("CenterCutCl stereo.wav -c stdout", @ScriptDir, @SW_SHOW, $STDOUT_CHILD)
While 1
    $sStdout &= StdoutRead($hPid,0,1)
    If @error Then ExitLoop
WEnd

$iSize = BinaryLen($sStdout)
ConsoleWrite($iSize & @CRLF)
Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Thank you ProgAndy! If you don't mind my asking, if using this in a playlist loop, is there anything else I should be clearing out to free up memory?

Joe

;Center
    $iSize = 0
        $sStdout = Binary("")
    $hPid = Run($SCC &  ' "' & $File &'"' & " -c stdout", @ScriptDir, @SW_HIDE, $STDOUT_CHILD)
    While 1
        $sStdout &= StdoutRead($hPid,0,1)
        If @error Then ExitLoop
    WEnd

    $iSize = BinaryLen($sStdout)
    $tStruct1 = DllStructCreate("byte[" & $iSize & "]")
    DllStructSetData($tStruct1, 1, $sStdout)
    $pStruct1 = DllStructGetPtr($tStruct1)

    $source3 = _BASS_StreamCreateFile(True, $pStruct1, 0, $iSize, $BASS_STREAM_DECODE)
    $si = _BASS_ChannelGetInfo($source3)
    $mixer3 = _BASS_Mixer_StreamCreate($si[0], 1, BitOR($BASS_SAMPLE_MONO, $BASS_SPEAKER_CENTER))
    $MixChannel3 = _BASS_Mixer_StreamAddChannel($mixer3, $source3, $BASS_STREAM_AUTOFREE)


;   LFE
    $iSize = 0
    $sStdout = Binary("")
    $hPid = Run($Sox & ' "' & $File  & '"' & " -c 1 -t wav - lowpass " & $LFEFreq & " gain " & $LFEGain, @ScriptDir, @SW_HIDE, $STDOUT_CHILD)
    While 1
        $sStdout &= StdoutRead($hPid,0,1)
        If @error Then ExitLoop
    WEnd


    $iSize = BinaryLen($sStdout)

    $tStruct2 = DllStructCreate("byte[" & $iSize & "]")
    DllStructSetData($tStruct2, 1, $sStdout)
    $pStruct2 = DllStructGetPtr($tStruct2)

    $source4 = _BASS_StreamCreateFile(True, $pStruct1, 0, $iSize, $BASS_STREAM_DECODE)
    $si = _BASS_ChannelGetInfo($source4)
    $mixer4 = _BASS_Mixer_StreamCreate($si[0], 1, BitOR($BASS_SAMPLE_MONO, $BASS_SPEAKER_LFE))
    $MixChannel4 = _BASS_Mixer_StreamAddChannel($mixer4, $source4, $BASS_STREAM_AUTOFREE)
Edited by a440hz

Are you experienced?

Link to comment
Share on other sites

  • 2 months later...

Sorry to disturb you all here, I have tried to look through everything related _Bass_ChannelGetData() in this thread and also in un4seen and the livespec.c, but I can't seems to get my code to read out the dominant freq of a 2-ch recording input. I am pumping in a 1KHz Sine wave tone from another pc.

I notice that my $pBuffer array in _Bass_ChannelGetData() is not filled with any data for my later frequency calculation. I have tested my $RecHandle using _Bass_ChannelGetLevel() that it's working. Also, my Bass.au3 is updated to the latest patch. Can anyone help me on this?

#include "Bass.au3"
#include "BassConstants.au3"
#include <WinAPI.au3>

;Configure Bass Audio Library
;----------------------------
Global Const $bass_dll = _BASS_Startup(@ScriptDir & "\bass.dll")
If @error = -1 Then
MsgBox(16, "ERROR!", "Could not load BASS.dll" & @CR & "Terminating... ")
Exit
EndIf
_BASS_SetConfig($BASS_CONFIG_REC_BUFFER, 1000)
_BASS_RecordInit(-1)

$Cnt = 0
$Name = _BASS_RecordGetInputName(0)
While $Name <> ""
$Input = _BASS_RecordGetInput($Cnt)
If BitAND($Input[0], $BASS_INPUT_TYPE_WAVE) Then _BASS_RecordSetInput($Cnt, $BASS_INPUT_TYPE_WAVE, 1)
$Cnt += 1
$Name = _BASS_RecordGetInputName($Cnt)
WEnd

If @OSVersion = "WIN_7" Or @OSVersion = "WIN_VISTA" Or @OSVersion = "WIN_2008" Then _BASS_RecordSetInput(0, $BASS_INPUT_TYPE_WAVE, 1)

$RecHandle = _BASS_RecordStart(44100, 2, _WinAPI_MakeLong(0, 10))  ;44.1Khz, 2-ch recording

While 1

Dim $FFT[2048]
;Set all array value to zero
For $i=0 To Ubound($FFT)-1
  $FFT[$i] = 0
Next
;Get freq data from Rec Src
$FFTData = _BASS_ChannelGetData($RecHandle, $FFT, $BASS_DATA_FFT4096)
If $FFTData = 0 Then
  ConsoleWrite("_Bass_ChannelGetData : " & @error & @CRLF)
Else
  ConsoleWrite("Bass Return = " & $FFTData & @CRLF)
EndIf
;Debug: Read out DC value
ConsoleWrite("DC Value = " & $FFT[0] & @CRLF)
;Find Peak freq bin
Dim $peak = 0
For $a=1 to 2047
  If $FFT[$a] > $FFT[$peak] Then
   $peak = $a
  EndIf
Next
;Read sample rate of Rec Src
$SampleRate = _BASS_ChannelGetInfo($RecHandle)
;Calculate freq in Hz
$freq = $peak * $SampleRate[0] / 4096    ;freq = bin * samplerate / fftsize

ToolTip("Sample Rate: " & $SampleRate[0] & @CRLF & "Channel Freq: " & $freq)

Sleep(100)

WEnd
Link to comment
Share on other sites

Hi

You have to use a callback function

(you can use $BASS_EXT_RecordProc from BassExt.au3/dll)

I wrote this example script some days ego:

#AutoIt3Wrapper_UseX64=n
#include "Bass.au3"
#include "BassExt.au3"

OnAutoItExitRegister("_FreeBass")
HotKeySet("{ESC}", "_Exit")

_BASS_Startup()
_BASS_EXT_Startup()

_BASS_RecordInit(-1)

$hRecord = _BASS_RecordStart(44100, 2, 0, $BASS_EXT_RecordProc)
$tFFT = DllStructCreate("float[4096]")
$pFFT = DllStructGetPtr($tFFT)

While 1
    _BASS_ChannelGetData($hRecord, $pFFT, $BASS_DATA_FFT8192)
    $fMax = 0
    $fFreq = 0
    For $i = 1 To 4096
        If DllStructGetData($tFFT, 1, $i) > $fMax Then
            $fMax = DllStructGetData($tFFT, 1, $i)
            $fFreq = $i * 44100 / 8190
        EndIf
    Next
    ToolTip("Frequency: " & Round($fFreq, 1) & "Hz")
    Sleep(50)
WEnd


Func _Exit()
    Exit
EndFunc   ;==>_Exit

Func _FreeBass()
    _BASS_RecordFree()
EndFunc   ;==>_FreeBass
Link to comment
Share on other sites

Thank you very much Eukalyptus!

That and BASS_ATTRIB_VOL did the trick. I was able to make the individual volume sliders work as well as the mute and solo buttons! I looked in your MP3DJ app to cheat ;) Very Cool!

Now on to making some VU Meters.

All the best,

Joe

Is there some example code for controlling the Mixer sliders?

I did a search for MP3DJ, but found nothing here.

Do you have a link to your code Joe?

Many Thanks.

EDIT: had a play with SET and GET Volume functions, which on my (Audigy SoundBlaster) controls the WAVE level output, not the Master sound level....

include <Bass.au3>
#include <BassConstants.au3>
#include <GUIConstantsEx.au3>
#include <SliderConstants.au3>
#include <WindowsConstants.au3>

; Name...........: _BASS_SetVolume
; Description ...: Sets the output master volume
; Syntax.........: _BASS_SetVolume($volume)
; Parameters ....:  -   $volume     -   The volume level... 0 (silent) to 1 (max).
; Return values .: Success      - Returns 1
;                  Failure      - Returns 0 and sets @ERROR to error returned by _BASS_ErrorGetCode()
;                                   @error will be set to-
;                                       - $BASS_ERROR_INIT      -   _BASS_Init has not been successfully called.
;                                       - $BASS_ERROR_NOTAVAIL  -   There is no volume control when using the "no sound" device.
;                                       - $BASS_ERROR_ILLPARAM  -   volume is invalid.
;                                       - $BASS_ERROR_UNKNOWN   -   Some other mystery problem!
;_BASS_SetVolume($Vol)

; Name...........: _BASS_GetVolume
; Description ...: Retrieves the current master volume level.
; Syntax.........: _BASS_GetVolume()
; Parameters ....:
; Return values .: Success      - Returns the current volume level.
;                  Failure      - Returns 0 and sets @ERROR to error returned by _BASS_ErrorGetCode()
;                                   @error will be set to-
;                                       - $BASS_ERROR_INIT      -   _BASS_Init has not been successfully called.
;                                       - $BASS_ERROR_NOTAVAIL  -   There is no volume control when using the "no sound" device.
;                                       - $BASS_ERROR_UNKNOWN   -   Some other mystery problem!

;_BASS_GetVolume($Vol)
;==============================================================================================================================

;Open Bass.DLL.  Required for all function calls.
_BASS_STARTUP ("BASS.dll")

;Initalize bass.  Required for most functions.
_BASS_Init(0, -1, 44100, 0, "")

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

$GetVol = _BASS_GetVolume()

If @error then MsgBox(0,"","Error = " &@error)


$hMain = GUICreate("", 50, 125, -1, -1, BitOR($WS_POPUP, $WS_BORDER), BitOR($WS_EX_TOPMOST, $WS_EX_CONTROLPARENT))

$Slider = GUICtrlCreateSlider(12, 24, 21, 97, $TBS_VERT)
$Vol_label = GUICtrlCreateLabel("Wav?", 6, 4, 33, 17)
GUICtrlSetData($Slider, 0)

GUICtrlSetLimit($Slider, 100, 1)

GUISetState(@SW_SHOW)

    Do
        $SetVol =  1 -GUICtrlRead($Slider)/100
        _BASS_SetVolume($SetVol)
        $GetVol = _BASS_GetVolume()
        $Pos = MouseGetPos()
        Tooltip($GetVol * 100,$pos[0]+ 20,$pos[1] + 10)
        $msg = GUIGetMsg()
    Sleep(10)
    Until $msg = $GUI_EVENT_CLOSE

    _BASS_SetVolume(1)
    _BASS_Free()
Exit
Edited by Lakes

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

Link to comment
Share on other sites

Thank you eukalyptus, so this BassExt.au3 is still under beta, hopes it can integrate into the BASS lib soon...Posted Image

Just one more question, because mine is a 2-ch stereo signal, I would like to read out the individual freq of each channel, should I set the _BASS_ChannelGETData() with $BASS_DATA_FFT_INDIVIDUAL or just use your _BASS_EXT_ChannelGetFFT() inside the BassExt.au3?

Hi

You have to use a callback function

(you can use $BASS_EXT_RecordProc from BassExt.au3/dll)

I wrote this example script some days ego:

#AutoIt3Wrapper_UseX64=n
#include "Bass.au3"
#include "BassExt.au3"

OnAutoItExitRegister("_FreeBass")
HotKeySet("{ESC}", "_Exit")

_BASS_Startup()
_BASS_EXT_Startup()

_BASS_RecordInit(-1)

$hRecord = _BASS_RecordStart(44100, 2, 0, $BASS_EXT_RecordProc)
$tFFT = DllStructCreate("float[4096]")
$pFFT = DllStructGetPtr($tFFT)

While 1
    _BASS_ChannelGetData($hRecord, $pFFT, $BASS_DATA_FFT8192)
    $fMax = 0
    $fFreq = 0
    For $i = 1 To 4096
        If DllStructGetData($tFFT, 1, $i) > $fMax Then
            $fMax = DllStructGetData($tFFT, 1, $i)
            $fFreq = $i * 44100 / 8190
        EndIf
    Next
    ToolTip("Frequency: " & Round($fFreq, 1) & "Hz")
    Sleep(50)
WEnd


Func _Exit()
    Exit
EndFunc   ;==>_Exit

Func _FreeBass()
    _BASS_RecordFree()
EndFunc   ;==>_FreeBass

Link to comment
Share on other sites

@Lakes: You can´t control the master slider of the windows mixer using bass.dll

there is an UDF that does this job; search for _SoundSetMasterVolume

@VAG: use the $BASS_DATA_FFT_INDIVIDUAL flag!

you will receive 4096 * NumberOfChannels float values (stereo = 8192)

stereo: 1:left,2:right,3:left,4:right...

3 channels: 1:first;2:second;3:third;4:first;5:second;6:third...

...

E

Link to comment
Share on other sites

Thank you eukalyptus, so this BassExt.au3 is still under beta, hopes it can integrate into the BASS lib soon...Posted Image

Under beta until the help file is finished... That's going to take a while! ;)
Link to comment
Share on other sites

  • 2 months later...

something like this?

#include "Bass.au3"
#include "BassMix.au3"
#include "BassEnc.au3"

;result:         0s                          10s
;output.wav:     |----------------------------|
;sample1.wav:       |----------|
;sample2.wav:             |----------------|
;sample3.wav:                      |-------------|

$iBufferSize = 20000 ; bytes

_BASS_Startup()
_BASS_MIX_Startup()
_BASS_Encode_Startup()

_BASS_Init(0, -1, 44100, 0, "")

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

$hStream2 = _BASS_StreamCreateFile(False, @ScriptDir & "\sample2.wav", 0, 0, $BASS_STREAM_DECODE)
_BASS_ChannelSetPosition($hStream2, _BASS_ChannelSeconds2Bytes($hStream2, 5), $BASS_POS_BYTE) ;sample offset: 5s

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

$hMixer = _BASS_Mixer_StreamCreate(44100, 2, BitOR($BASS_MIXER_END, $BASS_STREAM_DECODE))

_BASS_Mixer_StreamAddChannelEx($hMixer, $hStream1, BitOR($BASS_MIXER_FILTER, $BASS_STREAM_AUTOFREE), _
        _BASS_ChannelSeconds2Bytes($hMixer, 1), _BASS_ChannelSeconds2Bytes($hMixer, 4)) ;sample1.wav: start: 1s / duration: 4s

_BASS_Mixer_StreamAddChannelEx($hMixer, $hStream2, BitOR($BASS_MIXER_FILTER, $BASS_STREAM_AUTOFREE), _
        _BASS_ChannelSeconds2Bytes($hMixer, 3), _BASS_ChannelSeconds2Bytes($hMixer, 6)) ;sample2.wav: start: 3s (sample offset 5s) / duration: 6s

_BASS_Mixer_StreamAddChannelEx($hMixer, $hStream3, BitOR($BASS_MIXER_FILTER, $BASS_STREAM_AUTOFREE), _
        _BASS_ChannelSeconds2Bytes($hMixer, 6), _BASS_ChannelSeconds2Bytes($hMixer, 5)) ;sample3.wav: start: 6s / duration: 5s

_BASS_Encode_Start($hMixer, @ScriptDir & "\output.wav", $BASS_ENCODE_PCM)


$tBuffer = DllStructCreate("byte[" & $iBufferSize & "]")
$pBuffer = DllStructGetPtr($tBuffer)

$iBytesEncode = _BASS_ChannelSeconds2Bytes($hMixer, 10); max length of output.wav

For $i = 1 To $iBytesEncode Step $iBufferSize
    If $i + $iBufferSize <= $iBytesEncode Then
        _BASS_ChannelGetData($hMixer, $pBuffer, $iBufferSize)
    Else
        _BASS_ChannelGetData($hMixer, $pBuffer, $iBytesEncode - $i)
    EndIf
Next

_BASS_FREE()

there is a bug in BassMix.au3!

change line:

Local $BASS_ret_ = DllCall($_ghBassMixDll, "int", "BASS_Mixer_StreamAddChannelEx", "hwnd", $handle, "dword", $channel, "uint64", $length

to

Local $BASS_ret_ = DllCall($_ghBassMixDll, "int", "BASS_Mixer_StreamAddChannelEx", "hwnd", $handle, "dword", $channel, "dword", $flags, "uint64", $start, "uint64", $length)

E

Link to comment
Share on other sites

  • 3 weeks later...

Here you are:

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include "Bass.au3"
#include "BassEnc.au3"
#include "BassExt.au3"

Global $hRecord, $hEncoder, $bEncoderActive, $iTimer, $iSent

_BASS_Startup()
___Debug(@error, "load bass.dll")

_BASS_ENCODE_Startup()
___Debug(@error, "load bassenc.dll")

_BASS_EXT_Startup()
___Debug(@error, "load bassext.dll")

_BASS_RecordInit(-1)
___Debug(@error, "initialize recording device")

$hRecord = _BASS_RecordStart(44100, 2, 0, $BASS_EXT_RecordProc)
___Debug(@error, "start recording (using callback function from bassext.dll)")

$hEncoder = _BASS_Encode_Start($hRecord, @MyDocumentsDir & "\BASS_EXAMPLE.wav", $BASS_ENCODE_PCM)
___Debug(@error, "set up encoder on $hRecord stream (encoding to PCM)")

$iTimer = TimerInit()
While 1
    $bEncoderActive = _BASS_Encode_IsActive($hEncoder)
    If $bEncoderActive = $BASS_ACTIVE_PLAYING Then ___Debug(0, "encoder is running")
    If $bEncoderActive = $BASS_ACTIVE_PAUSED Then ___Debug(0, "encoder is paused")

    $iSent = _BASS_Encode_GetCount($hEncoder, $BASS_ENCODE_COUNT_IN)
    ___Debug(-1, "data sent to encoder : " & $iSent)

    If TimerDiff($iTimer) > 5000 Then ExitLoop
    Sleep(1000)
WEnd

_BASS_Encode_SetPaused($hEncoder, True)
___Debug(@error, "encoder paused")

$iTimer = TimerInit()
While 1
    $bEncoderActive = _BASS_Encode_IsActive($hEncoder)
    If $bEncoderActive = $BASS_ACTIVE_PLAYING Then ___Debug(0, "encoder is running")
    If $bEncoderActive = $BASS_ACTIVE_PAUSED Then ___Debug(0, "encoder is paused")

    $iSent = _BASS_Encode_GetCount($hEncoder, $BASS_ENCODE_COUNT_IN)
    ___Debug(-1, "data sent to encoder : " & $iSent)

    If TimerDiff($iTimer) > 5000 Then ExitLoop
    Sleep(1000)
WEnd


_BASS_Encode_Stop($hEncoder)
___Debug(@error, "stop encoder")

_BASS_RecordFree()
___Debug(@error, "free recording device")



Func ___DeBug($iError, $sAction)
    Switch $iError
        Case -1
            ConsoleWrite(@CRLF & "-" & $sAction & @CRLF)
        Case 0
            ConsoleWrite(@CRLF & "+" & $sAction & " - OK" & @CRLF)
        Case Else
            ConsoleWrite(@CRLF & "!" & $sAction & " - FAILED" & @CRLF)
            Exit
    EndSwitch
EndFunc   ;==>___DeBug
Link to comment
Share on other sites

You can usually safely ignore any AU3Check "Warnings" as they are usually just that, a warning that something doesn't appear to look right. Unless it's causing the script to not run, Warnings are generally ignorable in a UDF. Errors, on the other hand, should be taken note of as they are actual problems with a script.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Hi, great work! :graduated:. But, I have a slight problem. I want to be able to have bass only play one sound at a time, instead of mixing multiple sounds together. At the moment, I have a playerTest function that's activated with a hotKey. When I press the hotkey while the sound's still playing, I want it to stop the sound, and restart, or, start a new one. I can't get this to work, though. Any ideas? Here's the snippet of code, that later, will be part of a larger program, and generalized.

func playTest()
    local $stream = _bass_StreamCreateFile(0, "d:\music\test.wav", 0, 0, 0)
    if _bass_ChannelIsActive($stream) = $bass_active_playing then _bass_channelStop($stream)
    _bass_channelPlay($stream, 1)
EndFunc

HotKeySet("^{f1}", "playTest")
while 1
    sleep(200)
    WEnd
Link to comment
Share on other sites

#AutoIt3Wrapper_UseX64=n
#include "Bass.au3"

_BASS_Startup(@ScriptDir & "\bass.dll")
_BASS_Init(0, -1, 44100, 0, "")

Global $hStream_F1 = _BASS_StreamCreateFile(False, @ScriptDir & "\F1.wav", 0, 0, 0)
Global $hStream_F2 = _BASS_StreamCreateFile(False, @ScriptDir & "\F2.wav", 0, 0, 0)

Global $hStream_Current

HotKeySet("{ESC}", "_Exit")
HotKeySet("{F1}", "_Play")
HotKeySet("{F2}", "_Play")

While 1
    Sleep(100)
WEnd

Func _Play()
    _BASS_ChannelStop($hStream_Current)
    Switch @HotKeyPressed
        Case "{F1}"
            $hStream_Current = $hStream_F1
        Case "{F2}"
            $hStream_Current = $hStream_F2
    EndSwitch
    _BASS_ChannelPlay($hStream_Current, True)
EndFunc   ;==>_Play

Func _Exit()
    _BASS_ChannelStop($hStream_Current)
    _BASS_StreamFree($hStream_F1)
    _BASS_StreamFree($hStream_F2)
    _BASS_Free()
    Exit
EndFunc   ;==>_Exit

E

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...