Blitzbass and EAX

Blitz3D Forums/Blitz3D Programming/Blitzbass and EAX

JoshK(Posted 2004) [#1]
Anyone have an example of how to use EAX effects in BlitzBass? I want hardware EAX, not software DirectX "FX".

Here is a stripped-down example:
userdevice=0
BASS_Init(userdevice,44100,0,0)

BASS_Start()

sample=BASS_SampleLoad(0,"loop2.wav",0,0,1,0)
channel=BASS_SamplePlay(sample)


Repeat
Until KeyDown(1)

BASS_Stop()
BASS_Free()

End



JoshK(Posted 2004) [#2]
I got this. Now I have to figure out how to turn EAX off!

userdevice=0
BASS_Init(userdevice,44100,BASS_DEVICE_3D,0)
BASS_Start()

sample=BASS_SampleLoad(0,"loop2.wav",0,0,1,0)
channel=BASS_SamplePlay(sample)

BASS_SetEAXParameters EAX_ENVIRONMENT_GENERIC,1,4,1

Repeat
Until KeyDown(1)

BASS_Stop()
BASS_Free()
End



JoshK(Posted 2004) [#3]
Okay, I almost have a complete replacement of all the Blitz sound commands...it will work seamlessly with any program.

How do I find the flags in the sample structure? It looks to me like it is a word at "8", but that doesn't work:


// Sample info structure & flags
typedef struct {
0 DWORD freq; // default playback rate
2 DWORD volume; // default volume (0-100)
4 int pan; // default pan (-100=left, 0=middle, 100=right)
8 DWORD flags; // BASS_SAMPLE_xxx flags
DWORD length; // length (in samples, not bytes)
DWORD max; // maximum simultaneous playbacks
/* The following are the sample's default 3D attributes (if the sample
is 3D, BASS_SAMPLE_3D is in flags) see BASS_ChannelSet3DAttributes */
DWORD mode3d; // BASS_3DMODE_xxx mode
float mindist; // minimum distance
float maxdist; // maximum distance
DWORD iangle; // angle of inside projection cone
DWORD oangle; // angle of outside projection cone
DWORD outvol; // delta-volume outside the projection cone
/* The following are the defaults used if the sample uses the DirectX 7
voice allocation/management features. */
DWORD vam; // voice allocation/management flags (BASS_VAM_xxx)
DWORD priority; // priority (0=lowest, 0xffffffff=highest)
} BASS_SAMPLE;


JoshK(Posted 2004) [#4]
Nice conversation I am having with myself. Here are some sound replacement functions. No 3D yet:

Global BASSINITIALIZED

Function Load3DSound(file$)
Return LoadSound(file$)
End Function

Function InitSound(userdevice=0)
DebugLog "Initializing BASS..."
If Not BASS_Init(userdevice,44100,BASS_DEVICE_3D,0)
	BASS_Stop()
	BASS_Free()
	DebugLog "BASS failed to initialize."
	Return False
	EndIf
DebugLog "Initializing digital output..."
If Not BASS_Start()
	BASS_Stop()
	BASS_Free()	
	DebugLog "Failed to initialize digital output."
	Return False
	EndIf
BASSINITIALIZED=True
Return True
End Function

Function SetSoundEnvironment(effect,volume#=0.2,decay#=10.0,dampening#=1.0)
If effect=-1
	BASS_SetEAXParameters -1,0,0,0
	Else
	BASS_SetEAXParameters effect,volume,decay,dampening
	EndIf
End Function

Function LoadSound(file$)
If Not BASSINITIALIZED InitSound()
If Not BASSINITIALIZED Return
DebugLog "Loading sound "+Chr(34)+file+Chr(34)+"..."
noise=BASS_SampleLoad(0,file,0,0,3,0)

;BASS_SAMPLE_3D
If Not noise
	DebugLog "Failed to load sound "+Chr(34)+file+Chr(34)+"."
	EndIf
Return noise
End Function

Function EmitSound(sound,entity)
PlaySound sound
End Function

Function PlaySound(sound)
If Not BASSINITIALIZED Return
If sound Return BASS_SamplePlay(sound)
End Function

Function FreeSound(sound)
If Not BASSINITIALIZED Return
BASS_SampleFree(sound)
End Function

Const BASS_SAMPLE_FLAGS=8

Function LoopSound(sound)
If Not BASSINITIALIZED Return
bank=CreateBank(60)
BASS_SampleGetInfo(sound,bank)
flags=PeekShort(bank,12)
If Not (BASS_SAMPLE_LOOP And flags)
	flags=flags+BASS_SAMPLE_LOOP
	PokeShort bank,12,flags
	BASS_SampleSetInfo sound,bank
	EndIf
FreeBank bank
End Function



.rIKmAN.(Posted 2004) [#5]
Nice one halo.


Jeroen(Posted 2004) [#6]
Hi Halo,

No one is replying because you asked a question with using some sort of third-party tool, and most of the people here, I guess, don't know what all those BASS commands are.


Hotcakes(Posted 2004) [#7]
And then you answered it yourself and then you started rambling about stuff and by then it was too late to stop I suppose =]


Ziltch(Posted 2004) [#8]
People here are not that interested in sound.

I got very little feedback with the sound functions I have added to the archives.


Wayne(Posted 2004) [#9]
Sound is critical, I appreciate all the contributions you guys make.

Thank you


Hotcakes(Posted 2004) [#10]
What sound functions, Ziltch? =]


Ziltch(Posted 2004) [#11]
Creating Wav files and example

http://www.blitzbasic.com/codearcs/codearcs.php?code=1111
http://www.blitzbasic.com/codearcs/codearcs.php?code=1112

Windows Audio Mixer control
http://www.blitzbasic.com/codearcs/codearcs.php?code=847

Recording Audio and CD control
http://www.blitzbasic.com/codearcs/codearcs.php?code=845

That is some of them, more examples in the code archive.

I am also writing a MIDI library. Which can read/write to internal/external devices. Watching the sliders move by themselves on my new Midi controler is Cool!


Dirk Krause(Posted 2004) [#12]
Very good, can't wait to see that!