Jump to content

BASS Function Library (Sound and Music Functions)


BrettF
 Share

Recommended Posts

GOT IT!!!

Here it is, I forgot to make the mixer mono!

Thank You Guys!!!

#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], 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[3]
;~ $matrix[1] = $left
;~ $matrix[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

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

Func ExitFunctions ()
    _BASS_Stop()
    _BASS_Free()
EndFunc

Are you experienced?

Link to comment
Share on other sites

E,

It can be done. Using just BASS, BASSMIX and SoX I have created a working application. I can't give the formula away because I've been sworn to secrecy. I will have a demo app ready soon and if you have a 5.1 system I'll send you a wma so you can hear it.

I wouldn't need Sox if I could figure out how to make _BASS_ChannelSetFX work the parametric EQ as I could create the LFE with it.

My code:

#include <Bass.au3>
#include <BassMix.au3>
Global $fCenter, $fBandwidth,$fGain ; PARAMETRIC EQ
Global $LFEFX ; LFE Effect Handle
Global $mstructLFE,$mstruct
Global $channel4
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


; LFE

$channel4 = _BASS_StreamCreateFile(False, @ScriptDir & "\mono.wav", 0, 0, $BASS_SPEAKER_LFE); I've used other speaker assignments to test
$LFEFX = _BASS_ChannelSetFX($channel4, $BASS_FX_DX8_PARAMEQ, 1)
_SetLFE($channel4,80,1,Default)
_BASS_ChannelPlay($channel4, False)

While 1
    Sleep(50)
WEnd

;create a single band eq to lowpass everthing below 80hz (will be variable to 120hz eventually)
Func _SetLFE($LFEFX,$fCenter, $fBandwidth,$fGain)
    $mstructLFE = DllStructCreate("float[3]") ; Neither this nor the remmed out line works
    ;Local $mstructLFE = DllStructCreate("float;float;float")
    DllStructSetData($mstructLFE, 1, $fCenter,1)
    DllStructSetData($mstructLFE, 1, $fBandwidth,2)
    DllStructSetData($mstructLFE, 1, $fGain,3)
    _BASS_FXSetParameters($channel4, DllStructGetPtr($mstructLFE))

EndFunc

Func ExitFunctions ()
    _BASS_Stop()
    _BASS_Free()

EndFunc

Thanks,

Joe

I don´t think that it´s possible to create a stereo->5.1 upmix by only use phase reversing.

To do phaseshifting, STFT or whatever formular you use, you have to set up a DSP-callback and this can´t be done in pure autoit!

But you can create a DLL to do this.

Edited by a440hz

Are you experienced?

Link to comment
Share on other sites

Hi

I found a few bugs!

Bassfx.au3:

Line 60: Func _BASS_FX_Startup($sBassFXDll = "bassfx.dll") ===> Func _BASS_FX_Startup($sBassFXDll = "bass_fx.dll")

Bass.au3:

Line 3937: Assign("_gtBASS_FX_" & $BASS_ret_[0], Eval(StringReplace($type, "_FX", "")), 2) ===> Assign("BASS_FX_" & $BASS_ret_[0], Eval(StringReplace($type, "_FX", "")), 2)

Line 3985: $struct = DllStructCreate(Eval("_gtBASS_FX_" & $fxhandle)) ===> $struct = DllStructCreate(Eval("BASS_FX_" & $fxhandle))

Line 4015: Local $sRet = DllStructCreate(Eval("_gtBASS_FX_" & $fxhandle)) ===> Local $sRet = DllStructCreate(Eval("BASS_FX_" & $fxhandle))

The EQ should work now:

$LFEFX = _BASS_ChannelSetFX($channel4, $BASS_FX_DX8_PARAMEQ, 1)

_BASS_FXSetParameters($LFEFX, "80|1|-15")

BUT: this will setup only a small band at 80Hz; to create a lowpass you have to set more bands to cover the whole spectrum above 80Hz!

maybe it´s easier to use $BASS_BFX_LPF (see bass_fx.chm) (and don´t forget to call _BASS_FX_Startup in this case)

c.u.E

Edited by eukalyptus
Link to comment
Share on other sites

Fixed in my copy. I'll probably just upload another patch as I want to have the next version released with a help file... I'm automating it and even though its easier, it's sooo much work!

To fix errors noted by Eukalyptus, install Patch_9_2.

Cheers,

Brett

Edited by BrettF
Link to comment
Share on other sites

Thanks E!! :idea:

Easily tested with _BASS_FXSetParameters($LFEFX, "14000|32|-15")

If you don't mind my asking, how would I create additional bands?

I'm really bad at understanding DllStructCreate, I just learned about it the other day and have only cobbled together whatever I have from feedback I've gotten off the forum and shear luck. The help file actually did help solve a mystery for me but for the most part was too technical on the subject. I'll see what I can come up with for $BASS_BFX_PEAKEQ and BASS.Fx.

All the best,

Joe

Are you experienced?

Link to comment
Share on other sites

Thanks E!! :idea:

Easily tested with _BASS_FXSetParameters($LFEFX, "14000|32|-15")

If you don't mind my asking, how would I create additional bands?

I'm really bad at understanding DllStructCreate, I just learned about it the other day and have only cobbled together whatever I have from feedback I've gotten off the forum and shear luck. The help file actually did help solve a mystery for me but for the most part was too technical on the subject. I'll see what I can come up with for $BASS_BFX_PEAKEQ and BASS.Fx.

All the best,

Joe

There is a tutorial on using dlls in AutoIt... Have a search for that.
Link to comment
Share on other sites

Added BiQuad filters to BassFXConstants.au3

@a440hz: update your BassFXConstants.au3 and you can use the lopassfilter :idea:

_BASS_FX_Startup()

$LFEFX = _BASS_ChannelSetFX($channel4, $BASS_FX_BFX_BQF, 1)

_BASS_FXSetParameters($LFEFX, $BASS_BFX_BQF_LOWPASS & "|120|0|3|0|0|" & $BASS_BFX_CHANALL)

BassFXConstants.au3

#include-once
; ==========================================================================================================================================================
; Error codes returned by BASS_ErrorGetCode()
; ==========================================================================================================================================================
Global Const $BASS_ERROR_FX_NODECODE = 4000;    // Not a decoding channel
Global Const $BASS_ERROR_FX_BPMINUSE = 4001;    // BPM/Beat detection is in use

; ==========================================================================================================================================================
; Tempo / Reverse / BPM / Beat flag
; ==========================================================================================================================================================
Global Const $BASS_FX_FREESOURCE = 0x10000;      // Free the source handle as well?

; ==========================================================================================================================================================
; DSP channels flags
; ==========================================================================================================================================================
Global Const $BASS_BFX_CHANALL = -1;     // all channels at once (as by default)
Global Const $BASS_BFX_CHANNONE = 0;     // disable an effect for all channels
Global Const $BASS_BFX_CHAN1 = 1;        // left-front channel
Global Const $BASS_BFX_CHAN2 = 2;        // right-front channel
Global Const $BASS_BFX_CHAN3 = 4;        // see above info
Global Const $BASS_BFX_CHAN4 = 8;        // see above info
Global Const $BASS_BFX_CHAN5 = 16;       // see above info
Global Const $BASS_BFX_CHAN6 = 32;       // see above info
Global Const $BASS_BFX_CHAN7 = 64;       // see above info
Global Const $BASS_BFX_CHAN8 = 128;      // see above info

; ==========================================================================================================================================================
; BiQuad filters
; ==========================================================================================================================================================
Global Const $BASS_BFX_BQF_LOWPASS    = 0;
Global Const $BASS_BFX_BQF_HIGHPASS   = 1;
Global Const $BASS_BFX_BQF_BANDPASS   = 2;         // constant 0 dB peak gain
Global Const $BASS_BFX_BQF_BANDPASS_Q = 3;         // constant skirt gain, peak gain = Q
Global Const $BASS_BFX_BQF_NOTCH      = 4;
Global Const $BASS_BFX_BQF_ALLPASS    = 5;
Global Const $BASS_BFX_BQF_PEAKINGEQ  = 6;
Global Const $BASS_BFX_BQF_LOWSHELF   = 7;
Global Const $BASS_BFX_BQF_HIGHSHELF  = 8;

; ==========================================================================================================================================================
; DSP effects
; ==========================================================================================================================================================
Global Const $BASS_FX_BFX_ROTATE = "BASS_FX_BFX_ROTATE"
Global Const $BASS_FX_BFX_ROTATE_VALUE = 0x10000
Global Const $BASS_FX_BFX_ECHO = "BASS_FX_BFX_ECHO"
Global Const $BASS_FX_BFX_ECHO_VALUE = 0x10001
Global Const $BASS_FX_BFX_FLANGER = "BASS_FX_BFX_FLANGER"
Global Const $BASS_FX_BFX_FLANGER_VALUE = 0x10002
Global Const $BASS_FX_BFX_VOLUME = "BASS_FX_BFX_VOLUME"
Global Const $BASS_FX_BFX_VOLUME_VALUE = 0x10003
Global Const $BASS_FX_BFX_PEAKEQ = "BASS_FX_BFX_PEAKEQ"
Global Const $BASS_FX_BFX_PEAKEQ_VALUE = 0x10004
Global Const $BASS_FX_BFX_REVERB = "BASS_FX_BFX_REVERB"
Global Const $BASS_FX_BFX_REVERB_VALUE = 0x10005
Global Const $BASS_FX_BFX_LPF = "BASS_FX_BFX_LPF"
Global Const $BASS_FX_BFX_LPF_VALUE = 0x10006
Global Const $BASS_FX_BFX_MIX = "BASS_FX_BFX_MIX"
Global Const $BASS_FX_BFX_MIX_VALUE = 0x10007
Global Const $BASS_FX_BFX_DAMP = "BASS_FX_BFX_DAMP"
Global Const $BASS_FX_BFX_DAMP_VALUE = 0x10008
Global Const $BASS_FX_BFX_AUTOWAH = "BASS_FX_BFX_AUTOWAH"
Global Const $BASS_FX_BFX_AUTOWAH_VALUE = 0x10009
Global Const $BASS_FX_BFX_ECHO2 = "BASS_FX_BFX_ECHO2"
Global Const $BASS_FX_BFX_ECHO2_VALUE = 0x1000A
Global Const $BASS_FX_BFX_PHASER = "BASS_FX_BFX_PHASER"
Global Const $BASS_FX_BFX_PHASER_VALUE = 0x1000B
Global Const $BASS_FX_BFX_ECHO3 = "BASS_FX_BFX_ECHO3"
Global Const $BASS_FX_BFX_ECHO3_VALUE = 0x1000C
Global Const $BASS_FX_BFX_CHORUS = "BASS_FX_BFX_CHORUS"
Global Const $BASS_FX_BFX_CHORUS_VALUE = 0x1000D
Global Const $BASS_FX_BFX_APF = "BASS_FX_BFX_APF"
Global Const $BASS_FX_BFX_APF_VALUE = 0x1000E
Global Const $BASS_FX_BFX_COMPRESSOR = "BASS_FX_BFX_COMPRESSOR"
Global Const $BASS_FX_BFX_COMPRESSOR_VALUE = 0x1000F
Global Const $BASS_FX_BFX_DISTORTION = "BASS_FX_BFX_DISTORTION"
Global Const $BASS_FX_BFX_DISTORTION_VALUE = 0x10010
Global Const $BASS_FX_BFX_COMPRESSOR2 = "BASS_FX_BFX_COMPRESSOR2"
Global Const $BASS_FX_BFX_COMPRESSOR2_VALUE = 0x10011
Global Const $BASS_FX_BFX_VOLUME_ENV = "BASS_FX_BFX_VOLUME_ENV"
Global Const $BASS_FX_BFX_VOLUME_ENV_Value = 0x10012
Global Const $BASS_FX_BFX_BQF = "BASS_FX_BFX_BQF"
Global Const $BASS_FX_BFX_BQF_Value = 0x10013

Global Const $BASS_BFX_ECHO = 'float;' & _          ;fLevel         [0....1....n] linear
        'Int;' ;lDelay :        [1200..30000]

Global Const $BASS_BFX_FLANGER = 'float;' & _       ;fWetDry        [0....1....n] linear
        'float;' & _                                ;fSpeed         [0......0.09]
        'Int;' ;lChannel        BASS_BFX_CHANxxx flag/s

Global Const $BASS_BFX_VOLUME = 'Int;' & _          ;lChannel       BASS_BFX_CHANxxx flag/s or 0 for global volume control
        'float;' ;fVolume       [0....1....n] linear

Global Const $BASS_BFX_PEAKEQ = 'Int;' & _          ;lBand          [0...............n] more bands means more memory & cpu usage
        'float;' & _                                ;fBandwidth     [0.1.....4.......n] in octaves - Q is not in use (BW has a priority over Q)
        'float;' & _                                ;fQ             [0.......1.......n] the EE kinda definition (linear) (if Bandwidth is not in use)
        'float;' & _                                ;fCenter        [1Hz..<info.freq/2] in Hz
        'float;' & _                                ;fGain          [-15dB...0...+15dB] in dB
        'Int;' ;lChannel        BASS_BFX_CHANxxx flag/s

Global Const $BASS_BFX_REVERB = 'float;' & _        ;fLevel         [0....1....n] linear
        'Int;' ;lDelay          [1200..10000]

Global Const $BASS_BFX_LPF = 'float;' & _           ;fResonance     [0.01............10]
        'float;' & _                                ;fCutOffFreq    [1Hz....info.freq/2] cutoff frequency
        'Int;' ;lChannel        BASS_BFX_CHANxxx flag/s

Global Const $BASS_BFX_DAMP = 'float;' & _          ;fTarget        target volume level                      [0<......1] linear
        'float;' & _                                ;fQuiet         quiet  volume level                      [0.......1] linear
        'float;' & _                                ;fRate          amp adjustment rate                      [0.......1] linear
        'float;' & _                                ;fGain          amplification level                      [0...1...n] linear
        'float;' & _                                ;fDelay         delay in seconds before increasing level [0.......n] linear
        'Int;' ;lChannel        BASS_BFX_CHANxxx flag/s

Global Const $BASS_BFX_AUTOWAH = 'float;' & _       ;fDryMix        dry (unaffected) signal mix              [-2......2]
        'float;' & _                                ;fWetMix        wet (affected) signal mix                [-2......2]
        'float;' & _                                ;fFeedback      feedback                                 [-1......1]
        'float;' & _                                ;fRate          rate of sweep in cycles per second       [0<....<10]
        'float;' & _                                ;fRange         sweep range in octaves                   [0<....<10]
        'float;' & _                                ;fFreq          base frequency of sweep Hz               [0<...1000]
        'Int;' ;lChannel        BASS_BFX_CHANxxx flag/s

Global Const $BASS_BFX_ECHO2 = 'float;' & _         ;fDryMix        dry (unaffected) signal mix              [-2......2]
        'float;' & _                                ;fWetMix        wet (affected) signal mix                [-2......2]
        'float;' & _                                ;fFeedback      feedback                                 [-1......1]
        'float;' & _                                ;fDelay         delay sec                                [0<......6]
        'Int;' ;lChannel        BASS_BFX_CHANxxx flag/s

Global Const $BASS_BFX_PHASER = 'float;' & _        ;fDryMix        dry (unaffected) signal mix              [-2......2]
        'float;' & _                                ;fWetMix        wet (affected) signal mix                [-2......2]
        'float;' & _                                ;fFeedback      feedback                                 [-1......1]
        'float;' & _                                ;fRate          rate of sweep in cycles per second       [0<....<10]
        'float;' & _                                ;fRange         sweep range in octaves                   [0<....<10]
        'float;' & _                                ;fFreq          base frequency of sweep                  [0<...1000]
        'Int;' ;lChannel        BASS_BFX_CHANxxx flag/s

Global Const $BASS_BFX_ECHO3 = 'float;' & _         ;fDryMix        dry (unaffected) signal mix              [-2......2]
        'float;' & _                                ;fWetMix        wet (affected) signal mix                [-2......2]
        'float;' & _                                ;fDelay         delay sec                                [0<......6]
        'Int;' ;lChannel        BASS_BFX_CHANxxx flag/s

Global Const $BASS_BFX_CHORUS = 'float;' & _        ;fDryMix        dry (unaffected) signal mix              [-2......2]
        'float;' & _                                ;fWetMix        wet (affected) signal mix                [-2......2]
        'float;' & _                                ;fFeedback      feedback                                 [-1......1]
        'float;' & _                                ;fMinSweep      minimal delay ms                         [0<..<6000]
        'float;' & _                                ;fMaxSweep      maximum delay ms                         [0<..<6000]
        'float;' & _                                ;fRate          rate ms/s                                [0<...1000]
        'Int;' ;lChannel        BASS_BFX_CHANxxx flag/s

Global Const $BASS_BFX_APF = 'float;' & _           ;fGain          reverberation time                       [-1=<..<=1]
        'float;' & _                                ;fDelay         delay sec                                [0<....<=6]
        'Int;' ;lChannel        BASS_BFX_CHANxxx flag/s

Global Const $BASS_BFX_COMPRESSOR = 'float;' & _    ;fThreshold     compressor threshold                     [0<=...<=1]
        'float;' & _                                ;fAttacktime    attack time ms                           [0<.<=1000]
        'float;' & _                                ;fReleasetime   release time ms                          [0<.<=5000]
        'Int;' ;lChannel        BASS_BFX_CHANxxx flag/s

Global Const $BASS_BFX_DISTORTION = 'float;' & _    ;fDrive         distortion drive                         [0<=...<=5]
        'float;' & _                                ;fDryMix        dry (unaffected) signal mix              [-5<=..<=5]
        'float;' & _                                ;fWetMix        wet (affected) signal mix                [-5<=..<=5]
        'float;' & _                                ;fFeedback      feedback                                 [-1<=..<=1]
        'float;' & _                                ;fVolume        distortion volume                        [0=<...<=2]
        'Int;' ;lChannel        BASS_BFX_CHANxxx flag/s

Global Const $BASS_BFX_COMPRESSOR2 = 'float;' & _   ;fGain          output gain of signal after compression  [-60....60] in dB
        'float;' & _                                ;fThreshold     point at which compression begins        [-60.....0] in dB
        'float;' & _                                ;fRatio         compression ratio                        [1.......n]
        'float;' & _                                ;fAttack        attack time in ms                        [0.01.1000]
        'float;' & _                                ;fRelease       release time in ms                       [0.01.5000]
        'Int;' ;lChannel        BASS_BFX_CHANxxx flag/s

Global Const $BASS_BFX_ENV_NODE = 'double;' & _                  ; node position in seconds (1st envelope node must be at position 0)
        'float'                   ; node value

Global Const $BASS_BFX_VOLUME_ENV = 'int;' & _ ;lChannel: Integer;            // BASS_BFX_CHANxxx flag/s
        'int;' & _;lNodeCount: Integer;          // number of nodes
        'ptr;' & _;pNodes: PBASS_BFX_ENV_NODES;  // the nodes
        'bool' ;bFollow: BOOL;                // follow source position

Global Const $BASS_BFX_BQF = 'int;' & _;lFilter: Integer;             // BASS_BFX_BQF_xxx filter types
        'float;' & _;fCenter: FLOAT;               // [1Hz..<info.freq/2] Cutoff (central) frequency in Hz
        'float;' & _;fGain: FLOAT;                 // [-15dB...0...+15dB] Used only for PEAKINGEQ and Shelving filters in dB
        'float;' & _;fBandwidth: FLOAT;            // [0.1...........<10] Bandwidth in octaves (fQ is not in use (fBandwidth has a priority over fQ))(between -3 dB frequencies for BANDPASS and NOTCH or between midpoint(fGgain/2) gain frequencies for PEAKINGEQ)
        'float;' & _;fQ: FLOAT;                    // [0.1.............1] The EE kinda definition (linear) (if fBandwidth is not in use)
        'float;' & _;fS: FLOAT;                    // [0.1.............1] A "shelf slope" parameter (linear) (used only with Shelving filters)when fS = 1, the shelf slope is as steep as you can get it and remain monotonicallyincreasing or decreasing gain with frequency.
        'int';lChannel: Integer;            // BASS_BFX_CHANxxx flag/s


; ==========================================================================================================================================================
; tempo attributes (BASS_ChannelSet/GetAttribute)
; ==========================================================================================================================================================
Global Const $BASS_ATTRIB_TEMPO = 0x10000;
Global Const $BASS_ATTRIB_TEMPO_PITCH = 0x10001;
Global Const $BASS_ATTRIB_TEMPO_FREQ = 0x10002;

; ==========================================================================================================================================================
; tempo attributes options
; ==========================================================================================================================================================
Global Const $BASS_ATTRIB_TEMPO_OPTION_USE_AA_FILTER = 0x10010;    // TRUE / FALSE
Global Const $BASS_ATTRIB_TEMPO_OPTION_AA_FILTER_LENGTH = 0x10011;    // 32 default (8 .. 128 taps)
Global Const $BASS_ATTRIB_TEMPO_OPTION_USE_QUICKALGO = 0x10012;    // TRUE / FALSE
Global Const $BASS_ATTRIB_TEMPO_OPTION_SEQUENCE_MS = 0x10013;    // 82 default
Global Const $BASS_ATTRIB_TEMPO_OPTION_SEEKWINDOW_MS = 0x10014;    // 14 default
Global Const $BASS_ATTRIB_TEMPO_OPTION_OVERLAP_MS = 0x10015;    // 12 default

; ==========================================================================================================================================================
; reverse attribute (BASS_ChannelSet/GetAttribute)
; ==========================================================================================================================================================
Global Const $BASS_ATTRIB_REVERSE_DIR = 0x11000;

; ==========================================================================================================================================================
; playback directions
; ==========================================================================================================================================================
Global Const $BASS_FX_RVS_REVERSE = -1;
Global Const $BASS_FX_RVS_FORWARD = 1;

; ==========================================================================================================================================================
; bpm flags
; ==========================================================================================================================================================
Global Const $BASS_FX_BPM_BKGRND = 1;   // if in use, then you can do other processing while detection's in progress. (BPM/Beat)
Global Const $BASS_FX_BPM_MULT2 = 2;   // if in use, then will auto multiply bpm by 2 (if BPM < MinBPM*2)

; ==========================================================================================================================================================
; translation options
; ==========================================================================================================================================================
Global Const $BASS_FX_BPM_TRAN_X2 = 0;     // multiply the original BPM value by 2 (may be called only once & will change the original BPM as well!)
Global Const $BASS_FX_BPM_TRAN_2FREQ = 1;     // BPM value to Frequency
Global Const $BASS_FX_BPM_TRAN_FREQ2 = 2;     // Frequency to BPM value
Global Const $BASS_FX_BPM_TRAN_2PERCENT = 3;     // BPM value to Percents
Global Const $BASS_FX_BPM_TRAN_PERCENT2 = 4;     // Percents to BPM value
Link to comment
Share on other sites

Wow!! :idea:

Thank you kind soul. I'll look carefully at your code to learn as much as possible.

I appreciate yours and Brett's help with this!!

Maybe I can sneak in a little time during work today... :)

Are you experienced?

Link to comment
Share on other sites

E,

I haven't been able to hear any difference. I updated the au3 files - do I have the code right?

Thanks,

Joe

#include <Bass.au3>
#include <BassMix.au3>
#include <BassFx.au3>
Global $LFEFX ; LFE Effect Handle
Global $mstructLFE,$mstruct
Global $channel4
OnAutoItExitRegister("ExitFunctions")
_BASS_Startup()
_BASS_MIX_Startup()
_BASS_FX_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

; LFE
$channel4 = _BASS_StreamCreateFile(False, @ScriptDir & "\mono.wav", 0, 0, $BASS_SPEAKER_CENTER); I've used other speaker assignments to test
_BASS_ChannelPlay($channel4, False)
$LFEFX = _BASS_ChannelSetFX($channel4, $BASS_FX_BFX_BQF, 1)
_BASS_FXSetParameters($LFEFX, $BASS_BFX_BQF_LOWPASS & "|120|0|3|0|0|" & $BASS_BFX_CHANALL)
While 1
    Sleep(50)
WEnd

Func ExitFunctions ()
    _BASS_Stop()
    _BASS_Free()

EndFunc

Are you experienced?

Link to comment
Share on other sites

Link to comment
Share on other sites

Well that was a lot of work for nothing, but I learned quite a bit!

_BASS_PluginLoad("bassflac.dll") sure is easier!

Thanks :idea:

[Previous post deleted]

Edited by a440hz

Are you experienced?

Link to comment
Share on other sites

hello,

i use bass_asio examples, but not go. there are wrongs:

example_playfile.au3(13,48) : WARNING: $bass_asio_dll: possibly used before declaration.

$Samplerate = _BASS_ASIO_GetRate($bass_asio_dll)

i ask for example:

i want convert sampling rate of a wav file using bass.dll ...

is it possible?

tank.

Link to comment
Share on other sites

The bugs will be fixed in the next version of bass.au3 - thx

to resample a wav-file I would use BassMix.au3 and BassEnc to write the wav to disk:

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

_BASS_Startup()
_BASS_ENCODE_Startup()
_BASS_MIX_Startup()

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

Global $tBuffer = DllStructCreate("byte[20000]")
Global $pBuffer = DllStructGetPtr($tBuffer)
Global $iBuffer = DllStructGetSize($tBuffer)

$sFile = FileOpenDialog("Open...", "", "Wav Files (*.wav)")

$hMusicHandle = _BASS_StreamCreateFile(False, $sFile, 0, 0, $BASS_STREAM_DECODE)
$aInfo = _BASS_ChannelGetInfo($hMusicHandle)

$hMixer = _BASS_Mixer_StreamCreate(32000, $aInfo[1], BitOR($BASS_MIXER_END, $BASS_STREAM_DECODE))
_BASS_Mixer_StreamAddChannel($hMixer, $hMusicHandle, 0)

$hEncoder = _BASS_Encode_Start($hMixer, @ScriptDir & "\Resampled.wav", $BASS_ENCODE_PCM)

While _BASS_ChannelIsActive($hMixer)
    $iLength = _BASS_ChannelGetData($hMixer, $pBuffer, $iBuffer)
    _BASS_Encode_Write($hEncoder, $pBuffer, $iLength)
    ConsoleWrite($iLength & @CRLF)
WEnd

_BASS_Encode_Stop($hEncoder)
_BASS_StreamFree($hMixer)
_BASS_Free()
Link to comment
Share on other sites

many tanks.

but i receive this error:

Include\BassEnc.au3 (159) : ==> Subscript used with non-Array variable.:

Return SetError(0, "", $BASSENC_ret_[0])

Return SetError(0, "", $BASSENC_ret_^ ERROR

->17:45:17 AutoIT3.exe ended.rc:1

have you an idea?

Link to comment
Share on other sites

Make sure that you have bass.dll, bassenc.dll and bassmix.dll in the script directory

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

Global $iOutputFreq = 32000

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

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

_BASS_MIX_Startup()
___Debug(@error, "load bassmix.dll")

_BASS_Init(0, -1, 44100, 0, "")
___Debug(@error, "initialize bass")

Global $tBuffer = DllStructCreate("byte[20000]")
Global $pBuffer = DllStructGetPtr($tBuffer)
Global $iBuffer = DllStructGetSize($tBuffer)

$sFile = FileOpenDialog("Open...", "", "Wav Files (*.wav)")
___Debug($sFile = "", $sFile)

$hMusicHandle = _BASS_StreamCreateFile(False, $sFile, 0, 0, $BASS_STREAM_DECODE)
___Debug(@error, "create stream from file")
$aInfo = _BASS_ChannelGetInfo($hMusicHandle)
___Debug(@error, "get channel infos")

$hMixer = _BASS_Mixer_StreamCreate($iOutputFreq, $aInfo[1], BitOR($BASS_MIXER_END, $BASS_STREAM_DECODE))
___Debug(@error, "create mixer stream")

_BASS_Mixer_StreamAddChannel($hMixer, $hMusicHandle, 0)
___Debug(@error, "add channel to mixer")

$hEncoder = _BASS_Encode_Start($hMixer, @ScriptDir & "\Resampled.wav", $BASS_ENCODE_PCM)
___Debug(@error, "set up encoder")

$iBytes = _BASS_ChannelGetLength($hMusicHandle, $BASS_POS_BYTE)
___Debug(@error, "get filesize: " & $iBytes)

$iBytes=$iBytes * $iOutputFreq / $aInfo[0]
$iDone = 0

While _BASS_ChannelIsActive($hMixer)
    $iLength = _BASS_ChannelGetData($hMixer, $pBuffer, $iBuffer)
    ___Debug(@error, "read data: " & $iLength & " bytes")

    $iDone+=$iLength
    ___Debug(-1, Round($iDone * 100 / $iBytes) & "% done")
WEnd

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

_BASS_StreamFree($hMixer)
___Debug(@error, "free stream")

_BASS_Free()
___Debug(@error, "free bass")

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

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