Looping a file with bass.dll Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Tulevik
Posts: 36
Joined: 03 Jul 2015, 11:56

Looping a file with bass.dll

Post by Tulevik » 25 Jun 2022, 12:08

The selected file doesn't loop with the following code:

Code: Select all

#NoEnv
SetBatchLines -1
ListLines Off
 
BASS_DLLCALL:= DllCall("LoadLibrary","str",A_ScriptDir "\bass.dll") 	;	Load Bass.dll
BASS_Init:= DllCall(A_ScriptDir . "\bass.dll\BASS_Init",Int,-1,UInt,44100,Int,0,UInt,0,UInt,0)		;	initialise Bass
song:= DllCall(A_ScriptDir "\bass.dll\BASS_StreamCreateFile", Int, 0, Astr, "2.ogg", Uint, 0, Uint, 0, Uint, 0, Uint, 0)	;	Create Stream or Buff in Memory; song is the handle
BASS_ChannelFlags:=DllCall(A_ScriptDir . "\bass.dll\BASS_ChannelFlags", UInt, song, Astr, BASS_SAMPLE_LOOP, Astr, BASS_SAMPLE_LOOP)	;	Loops the file
BASS_ChannelPlay:=DllCall(A_ScriptDir . "\bass.dll\BASS_ChannelPlay", UInt, song, Int, 1)	;	Starts playback
return
q:: 
	DllCall(A_ScriptDir "\bass.dll\BASS_Free")	;	Free Bass Contents
	ExitApp
return
What's wrong with the loop dll call? Should I have declared that earlier?

Descolada
Posts: 1099
Joined: 23 Dec 2021, 02:30

Re: Looping a file with bass.dll  Topic is solved

Post by Descolada » 25 Jun 2022, 12:36

Just looking at the documentation of the BASS library, I would guess something like this:

Code: Select all

BASS_ChannelFlags:=DllCall(A_ScriptDir . "\bass.dll\BASS_ChannelFlags", UInt, song, UInt, BASS_SAMPLE_LOOP := 4, UInt, BASS_SAMPLE_LOOP := 4)
If you try calling it with BASS_SAMPLE_LOOP, AHK will assume it is a variable and use its value (which is empty). You need to pass the enumeration value of BASS_SAMPLE_LOOP, which in BASSFlag Enumeration is 4.

Tulevik
Posts: 36
Joined: 03 Jul 2015, 11:56

Re: Looping a file with bass.dll

Post by Tulevik » 25 Jun 2022, 13:00

Thank you, that worked! :bravo:

It seems to be enough to put the numbers (the fours):

Code: Select all

BASS_ChannelFlags:=DllCall(A_ScriptDir . "\bass.dll\BASS_ChannelFlags", UInt, song, UInt, 4, UInt, 4)

Post Reply

Return to “Ask for Help (v1)”