Page 1 of 1

64 bit Problem - weird result

Posted: Thu May 13, 2010 8:30 pm
by Perkin
Hi
Just started using 64 bit Windows7, PB x64 (b4) and am having a problem with a BASS 64bit dll I'm trying.
When using all the 32bit versions on my old system it worked fine.

I'm trying to use the commands from the lib (after initialising etc.)

BASS_ChannelBytes2Seconds(Handle, BASS_ChannelGetLength(Handle, #BASS_POS_BYTE))
and
BASS_ChannelBytes2Seconds(Handle, BASS_ChannelGetPosition(Handle, #BASS_POS_BYTE))

but both are returning the value '-1.#IND'

I would like anybody's help, to figure out what's causing the problem;
BASS, PB or Win7

My guess is the BASS dll, but I just want to be sure.

If code example is required, and details of BASS lib etc, they can be provided, just let me know.

Re: 64 bit Problem - weird result

Posted: Thu May 13, 2010 8:56 pm
by ts-soft
You Import the Bass.lib or loading Dynamical with Prototypes?
Without code and some more information we can't help you.

greetings
Thomas

Re: 64 bit Problem - weird result

Posted: Thu May 13, 2010 9:15 pm
by Perkin
Using Rescator' includes originally from topic http://www.purebasic.fr/english/viewtop ... 14&t=31784
Available in PB includes at http://un4seen.com/
Also used BASSx64 from site as well

Trying following code

Code: Select all

EnableExplicit
IncludeFile "bass.pbi"

Global *BASS_Filename
Procedure SetBASSFilename(filename.s)
  If *BASS_Filename
    FreeMemory(*BASS_Filename)
  EndIf
  *BASS_FILENAME = AllocateMemory(Len(filename) + 1)
  PokeS(*BASS_FILENAME, filename, -1, #PB_Ascii)
EndProcedure


If OpenWindow(0, 0, 0, 210, 220, "TEST", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget)

BASS_Init(-1, 44100, 0, WindowID(0), #Null)

Define Handle, songname.s, tLen.d, tPos.d, i.i


BASS_StreamFree(Handle)

; CHANGE THIS TO POINT TO AN EXISTING FILE
songname = "F:\_PureBasic\101 - Solsbury Hill.mp3"

SetBASSFilename(songname)

Handle = BASS_StreamCreateFile(0, *BASS_Filename, 0, 0, 0)
Debug Handle ; returns a valid result

; If i seperate the BASS_ChannelGetLength, it does return a valid amount.
tLen = BASS_ChannelBytes2Seconds(Handle, BASS_ChannelGetLength(Handle, #BASS_POS_BYTE))
Debug tLen ; this is where problem is - -1.#IND

BASS_ChannelPlay(Handle, 0)

;just to see if there's variation
For i = 1 To 5
  tPos = BASS_ChannelBytes2Seconds(Handle, BASS_ChannelGetPosition(Handle, #BASS_POS_BYTE))
  Debug tPos ; should alter with time but returns -1.#IND
  Delay(1000)
Next

EndIf

BASS_PluginFree(0)
BASS_StreamFree(Handle)
BASS_Free()
Anything else needed?

As I said, using 32bit OS/PB/BASS, all worked fine.
So I can't figure out which is my problem.

Re: 64 bit Problem - weird result

Posted: Thu May 13, 2010 9:33 pm
by ts-soft
Sorry, i can't find any link to the PB-Includes :oops:

Re: 64 bit Problem - weird result

Posted: Thu May 13, 2010 9:36 pm
by Perkin
Direct link for the includes are available in this post

http://www.purebasic.fr/english/viewtop ... 42#p308242

Edit: I downloaded the x64 version of Bass lib from http://www.un4seen.com/stuff/bass24-x64.zip

Re: 64 bit Problem - weird result

Posted: Thu May 13, 2010 10:11 pm
by ts-soft

Code: Select all

BASS_ChannelBytes2Seconds.d(handle.l,pos.q)
A handle is always a INTEGER and not a LONG. On 32-Bit you can put a handle in a long but
not on x64!

There is somethings to change on the include.

Code: Select all

BASS_Init(device.l,freq.l,flags.l,win.l,*dsguid)
win.i
And most of the Importresults like .l should .i

The importfile is not designed to work on x64

Code: Select all

Structure BASS_FILEPROCS
	*close.l
	*length.l
	*read.l
	*seek.l
EndStructure
This a pointers, have always the size of integer and not long. A pointer can be structured but not a
normal type like long, float and so on, remove the extension!
(PB-Compiler ignores this incorrect syntax but i would change that)

greetings
Thomas

Re: 64 bit Problem - weird result

Posted: Thu May 13, 2010 10:53 pm
by Perkin
ts-soft, I thought that may be the case, but the other commands I'd been using seemed to be working.
Anyway, I've changed the following in the bass.pbi :-

Changed structures (cut&paste each one over originals)

Code: Select all

Structure BASS_DEVICEINFO
	*name.i   ;description
	*driver.i ;driver
	flags.l
EndStructure

Structure BASS_CHANNELINFO
	freq.l 	    ;default playback rate
	chans.l     ;channels
	flags.l     ;BASS_SAMPLE/STREAM/MUSIC/SPEAKER flags
	ctype.l     ;type of channel
	origres.l   ;original resolution
	plugin.l    ;plugin handle
	sample.l    ;sample
 *filename.i ;filename
EndStructure

Structure BASS_PLUGINFORM
	ctype.l ;channel type
	*name.i ;format description
	*exts.i ;file extension filter (*.ext1;*.ext2;etc...)
EndStructure

Structure BASS_FILEPROCS
	*close.i
	*length.i
	*read.i
	*seek.i
EndStructure
Changed Imports to,

Code: Select all

Import "bass.lib"
 BASS_SetConfig.i(option.l,value.l)
 BASS_GetConfig.i(option.l)
 BASS_SetConfigPtr.i(option.l,value$)
 BASS_GetConfigPtr.i(option.l)
 BASS_GetVersion.i()
 BASS_ErrorGetCode.i()
 BASS_GetDeviceInfo.i(device.i,*info.BASS_DEVICEINFO)
 CompilerIf #PB_Compiler_OS=#PB_OS_Windows
  BASS_Init.i(device.l,freq.l,flags.l,win.i,*dsguid)
 CompilerElse
  BASS_Init.i(device.l,freq.l,flags.l,*win,*dsguid)
 CompilerEndIf
 BASS_SetDevice.i(device.i)
 BASS_GetDevice.i()
 BASS_Free.i()
 CompilerIf #PB_Compiler_OS=#PB_OS_Windows
  BASS_GetDSoundObject.i(object.l)
 CompilerEndIf
 BASS_GetInfo.i(*info)
 BASS_Update.i(length.l)
 BASS_GetCPU.f()
 BASS_Start.i()
 BASS_Stop.i()
 BASS_Pause.i()
 BASS_SetVolume.i(volume.f)
 BASS_GetVolume.f()
 
 BASS_PluginLoad.i(file$,flags.l)
 BASS_PluginFree.i(handle.i)
 BASS_PluginGetInfo.i(handle.i)
 
 BASS_Set3DFactors.i(distf.f,rollf.f,doppf.f)
 BASS_Get3DFactors.i(*distf.f,*rollf.f,*doppf.f)
 BASS_Set3DPosition.i(*pos.BASS_3DVECTOR,*vel.BASS_3DVECTOR,*front.BASS_3DVECTOR,*top.BASS_3DVECTOR)
 BASS_Get3DPosition.i(*pos.BASS_3DVECTOR,*vel.BASS_3DVECTOR,*front.BASS_3DVECTOR,*top.BASS_3DVECTOR)
 BASS_Apply3D.i()
 CompilerIf #PB_Compiler_OS=#PB_OS_Windows
  BASS_SetEAXParameters.i(env.l,vol.f,decay.f,damp.f)
  BASS_GetEAXParameters.i(*env.l,*vol.f,*decay.f,*damp.f)
 CompilerEndIf
 
 BASS_MusicLoad.i(mem.i,*file,offset.q,length.l,flags.l,freq.l)
 BASS_MusicFree.i(handle.i)
 
 BASS_SampleLoad.i(mem.i,*file,offset.q,length.l,max.l,flags.l)
 BASS_SampleCreate.i(length.l,freq.l,chans.l,max.l,flags.l)
 BASS_SampleFree.i(handle.i)
 BASS_SampleSetData.i(handle.i,*buffer)
 BASS_SampleGetData.i(handle.i,*buffer)
 BASS_SampleGetInfo.i(handle.i,*info.BASS_SAMPLE)
 BASS_SampleSetInfo.i(handle.i,*info.BASS_SAMPLE)
 BASS_SampleGetChannel.i(handle.i,onlynew.l)
 BASS_SampleGetChannels.i(handle.i,*channels.i)
 BASS_SampleStop.i(handle.i)
 
 BASS_StreamCreate.i(freq.l,chans.l,flags.l,*proc,*user)
 BASS_StreamCreateFile.i(mem.i,*file,offset.q,length.q,flags.l)
 BASS_StreamCreateURL.i(url.p-ascii,offset.l,flags.l,*proc,*user)
 BASS_StreamCreateFileUser.i(system.i,flags.l,*proc,*user)
 BASS_StreamFree.i(handle.i)
 BASS_StreamGetFilePosition.q(handle.i,mode.l)
 BASS_StreamPutData.i(handle.i,*buffer,length.l)
 BASS_StreamPutFileData.i(handle.i,*buffer,length.l)
 
 BASS_RecordGetDeviceInfo.i(device.i,*info.BASS_DEVICEINFO)
 BASS_RecordInit.i(device.i)
 BASS_RecordSetDevice.i(device.i)
 BASS_RecordGetDevice.i()
 BASS_RecordFree.i()
 BASS_RecordGetInfo.i(*info.BASS_RECORDINFO)
 BASS_RecordGetInputName.i(input.i)
 BASS_RecordSetInput.i(input.i,flags.l,volume.f)
 BASS_RecordGetInput.i(input.i,*volume.f)
 BASS_RecordStart.i(freq.l,chans.l,flags.l,*proc,*user)
 
 BASS_ChannelBytes2Seconds.d(handle.i,pos.q)
 BASS_ChannelSeconds2Bytes.q(handle.i,pos.d)
 BASS_ChannelGetDevice.i(handle.i)
 BASS_ChannelSetDevice.i(handle.i,device.i)
 BASS_ChannelIsActive.i(handle.i)
 BASS_ChannelGetInfo.i(handle.i,*info.BASS_CHANNELINFO)
 BASS_ChannelGetTags.i(handle.i,tags.l)
 BASS_ChannelFlags.i(handle.i,flags.l,mask.l)
 BASS_ChannelUpdate.i(handle.i,length.l)
 BASS_ChannelLock.i(handle.i,lock.l)
 BASS_ChannelPlay.i(handle.i,restart.l)
 BASS_ChannelStop.i(handle.i)
 BASS_ChannelPause.i(handle.i)
 BASS_ChannelSetAttribute.i(handle.i,attrib.l,value.f)
 BASS_ChannelGetAttribute.i(handle.i,attrib.l,*value.f)
 BASS_ChannelSlideAttribute.i(handle.i,attrib.l,value.f,time.l)
 BASS_ChannelIsSliding.i(handle.i,attrib.l)
 BASS_ChannelSet3DAttributes.i(handle.i,mode.i,min.f,max.f,iangle.l,oangle.l,outvol.f)
 BASS_ChannelGet3DAttributes.i(handle.i,*mode.i,*min.f,*max.f,*iangle.l,*oangle.l,*outvol.f)
 BASS_ChannelSet3DPosition.i(handle.i,*pos.BASS_3DVECTOR,*orient.BASS_3DVECTOR,*vel.BASS_3DVECTOR)
 BASS_ChannelGet3DPosition.i(handle.i,*pos.BASS_3DVECTOR,*orient.BASS_3DVECTOR,*vel.BASS_3DVECTOR)
 BASS_ChannelGetLength.q(handle.i,mode.i)
 BASS_ChannelSetPosition.i(handle.i,pos.q,mode.i)
 BASS_ChannelGetPosition.q(handle.i,mode.i)
 BASS_ChannelGetLevel.i(handle.i)
 BASS_ChannelGetData.i(handle.i,*buffer,length.l)
 BASS_ChannelSetSync.i(handle.i,type.l,param.q,*proc,*user)
 BASS_ChannelRemoveSync.i(handle.i,sync.l)
 BASS_ChannelSetDSP.i(handle.i,*proc,*user,priority.l)
 BASS_ChannelRemoveDSP.i(handle.i,dsp.i)
 BASS_ChannelSetLink.i(handle.i,chan.l)
 BASS_ChannelRemoveLink.i(handle.i,chan.l)
 BASS_ChannelSetFX.i(handle.i,type.l,priority.l)
 BASS_ChannelRemoveFX.i(handle.i,fx.l)
 
 BASS_FXSetParameters.i(handle.i,*params)
 BASS_FXGetParameters.i(handle.i,*params)
 BASS_FXReset.i(handle.i)
EndImport
Still getting the same problem, any other help or suggestions?

The 'BASS_ChannelGetPosition()' command in the testcode is returning a valid number which is incrementing while the sound is playing, so I think it may be a prob with the 'BASS_ChannelBytes2Seconds()' command. I looked on BASS forum, and no-one there seems to have flagged this as a problem there.

Re: 64 bit Problem - weird result

Posted: Thu May 13, 2010 11:09 pm
by ts-soft

Code: Select all

;- BASS Structures
Structure BASS_CHANNELINFO
	freq.l 	    ;default playback rate
	chans.l     ;channels
	flags.l     ;BASS_SAMPLE/STREAM/MUSIC/SPEAKER flags
	ctype.l     ;type of channel
	origres.l   ;original resolution
	plugin.l    ;plugin handle
	sample.l    ;sample
 *filename.l ;filename
EndStructure
i think plugin.i (it's a handle) and sample.i
and in your import there somethink named object, this should a integer.
You have to read the bass.h
Only types as DWORD a Long
Types beginning with h always Integer
and so on :wink:

I haven't the time to correct this all.

Greetings
Thomas

Re: 64 bit Problem - weird result

Posted: Thu May 13, 2010 11:33 pm
by Perkin
ts-soft, I'll go through it again, thanks.
(I didn't think I did it completely correct)

After searching for different things on BASS forum, I found some info.
I've got a workaround at the moment, I've done my own replacement command, till I get the include sorted.
I just include this proc, and alter any references to original command.

Code: Select all

Procedure.d X_BASS_ChannelBytes2Seconds(handle.i, pos.q)
  Protected byt_len.q, ci.BASS_CHANNELINFO, sec_len.d
  BASS_ChannelGetInfo(handle, @ci)
  sec_len = pos/ci\freq/ci\chans
  If ci\flags = #BASS_SAMPLE_FLOAT
    sec_len/4
  ElseIf Not(ci\flags = #BASS_SAMPLE_8BITS)
    sec_len/2
  EndIf
  ProcedureReturn sec_len
EndProcedure

Re: 64 bit Problem - weird result

Posted: Fri May 14, 2010 12:20 am
by Perkin
I changed the others as you suggested and went through the whole include alongside the bass.h file.
A few other changes. BOOL returns I made as .i, and the 'int' definitions I made as .i as well
Do you think that should be?

Still having the problem with that command.

Going through the bass.h, I need to work out when a DWORD is a .l, or a .i
(or if it's just pretending to be :lol: )

Re: 64 bit Problem - weird result

Posted: Fri May 14, 2010 12:26 am
by ts-soft
The problem is, the 64-bit version comes without a bass.h and the version from 32-bit
is only for the 32-bit version :?

Re: 64 bit Problem - weird result

Posted: Fri May 14, 2010 12:36 am
by Perkin
Thanks, I knew that it was for the 32bit version, but I thought if would have been fairly easy to change it to work on the 64bit version.

I thought it would just be updating the handles and pointers, but I was wrong, there's obviously something missing (apart from my brain).

I'll have another look on the BASS forum and see what I can find.

Thanks ts-soft.

Re: 64 bit Problem - weird result

Posted: Fri May 14, 2010 7:39 pm
by Rescator
First of all, yeah it looks like the old includes I did was 32bit only, I can't even recall if at the time PureBasic x64 was available yet.
But if there are any .i in there then probably yeah, if not then no.

BASS x64 is still Beta. (it's still not solid, and many of the plugins and support dll's aren't x64 yet)

Once BASS x64 is no longer Beta I'll go over the includes.
Reason I haven't updated the includes to support x64 is that I simply haven't done any work in a while where I needed BASS, let alone BASS x64.

But once BASS x64 is out of beta (unlike now where it's just a link to a the support forum) I'll go over the includes and make sure that both x86 and x64 are up-to-date,
as there has also been a few minor changes to the includes over the last few revisions. Once they've been updated I'll send'em to Ian so he can put them on the site like the current PureBasic x86 includes)

I check the un4seen.com now and again so once BASS x64 is out of beta I'll get on it,
and if it takes too long after it's release then feel free to message me here on the forum and nag me about it. :)
(You could do so on the un4seen forum too as I'm "Rescator" there as well, but not really that active unlike here.)

Re: 64 bit Problem - weird result

Posted: Fri May 14, 2010 8:03 pm
by Perkin
Thanks.