get bitrate

Blitz3D Forums/Blitz3D Programming/get bitrate

Hi all :) I was wondering if someone could show me an example of how to get the EXACT bitrates of both a file & stream in all music files using ONLY Blitz bass commands.

Thanks!

For this you must wrap a pointer (as i dont have made functions yet)

for a channel look at the "BASS_ChannelGetInfo" command (you will find simular for streams)

First you must create a "bank" and give this bank to bass with the channel asked.

infobank = CreateBank (2048) ; make shure that the bank is big enought)
BASS_ChannelGetInfo (mychannel,infobank)


now all the informations of this channel (see bass,chm) are stored in this bank and you can read them out. For an example how to read out a bank see the demo_getdeviceinfo where i do this with the BASS_GetInfo command.

bye

i wouldve posted a bit sooner, but the forums were down. so anyway. can u show me a working example using an mp3 instead of 2 lines? like i said, thats the only way i learn. if u arent willing to help me, i do have another forum i can ask the same question on no offense to anyone :)

Thanks again! :)

~DS~

http://www.un4seen.com/forum/?action=profile;u=4468;sa=showPosts ;)

Yes Abrexxes, I see u figured it out. Hehe :) So can you help? If not I'll ask them how on un4seen, I dont have a problem w/ that :)

Thanks! :)

~DS~

Ok, I've done some research, and I came up with this:

Site:

http://en.wikipedia.org/wiki/Audio_bit_depth

Bit rate = (bit depth) x (sampling rate) x (number of channels)

Now my question is. How can I figure out the 3 variables in the formula which are: bit depth, sampling rate, and number of channels?

If possible, I would like to see a tutorial, and not just some random variable that I barely understand.

Thanks, and good night :)

~DS~

All the information you need is in the BASS_CHANNELINFO struct which gets filled by BASS_ChannelGetInfo. But Abrexxes already told you that two weeks ago.

I know. But in order to learn, I need a working example from a code. I've read the help file, but it doesnt show how to use it with actual code. And I honestly dont care for c++. I don't know c++. That's why I chose BlitzBasic.

If you want a working example of using BASS_ChannelGetInfo to retrieve the information you want, give me a non-working example and I'll try to figure out where you're going wrong.

May I have permission to email you the code? It's sorta long. But I've marked the area(s) I need help with, which are very few areas.

Thanks Gabriel :)

~DS~

No, I don't want to have to deal with it in email. Please post it here. I can't imagine how it can be more than a couple of dozen lines.

ok, here's the closest i could do. Im not a genius, but I hope u get it.
You need bass of course along w/ dreamplayer's newest DLL to use this

2 probs in this 1. I cant get the song name / song to play any, and im not sure how to get it to return anything other than the info bank using Bass_ChannelGetInfo().

;BassInfo

Global FBassHandle
Global DropPath

Global DropFile
Global infobank

Graphics3D 800, 600, 0, 2

;Includes
Include "bass.bb"

dp_RequestFiles("*.mp3|*.mp3;*.mp3")

			DropPath=dp_RequestedPath()
			DropQuant=dp_RequestedFileCount()
			
			;Delete old files
			If DragDrop=1 Then
				If DropQuant>0 Then
					TrackPos=0
					TrackAnz=0
					BASS_ChannelStop(BassHandle)
				End If
			End If
			
			For DropCount=0 To DropQuant-1
				DropFile=dp_RequestedPath()+""+dp_RequestedFile(DropFile)
			Next

FBassHandle=BASS_StreamCreateFile(0,DropFile,0,0,BASS_MUSIC_FLOAT)
BASS_ChannelPlay(FBassHandle,BASS_TRUE)
infobank = CreateBank (4096) ; make shure that the bank is big enought)
BASS_ChannelGetInfo(FBassHandle,infobank)

While Not KeyHit(1)

If DropFile<>""
Text 10, 10, "Song:"+DropFile

Text 10, 30, "infobank:"+infobank

Else

Text 10, 10, "Song not loaded into memory"

EndIf

UpdateWorld
RenderWorld

Flip

Wend

End


Thanks for helping! :)

~DS~

I'm not sure how much help I'm going to be. I've downloaded the userlib and the player, and all the demos which come with the userlib crash when I run them. They don't play any audio, they just hang the machine. I know it's nothing to do with Bass itself, because I use Bass in my game. So I have to assume it's something with the userlib.

I can tell you that the reason you can't hear any sound is that you're not even initializing bass.

I can't test any of the code for BASS_ChannelGetInfo for the reasons I've already stated, but I'll give you the code I would have tried first. There could be errors, but since I can't run anything with BBS, I can't find or fix them. But maybe you can give it a go, or maybe someone who can actually run BBS can help you further.

Local infobank = CreateBank (32) ; DON'T RANDOMLY GUESS THE SIZE OF THE BANK. RESEARCH THE CALL AND FIND OUT HOW BIG THE DATA IS
; GOING TO BE. IN THIS CASE, IT APPEARS TO BE 8 INTEGERS. EACH INTEGER IS 4 BYTES, AND THAT'S 32 BYTES TOTAL.
BASS_ChannelGetInfo(FBassHandle,infobank)
Global Frequency%=PeekInt(infobank,0)
Global Channels%=PeekInt(infobank,4)
Global Flags%=PeekInt(infobank,8)
Global CType=PeekInt(infobank,12)
Global OriginalRes%=PeekInt(infobank,16)
Global Plugin%=PeekInt(infobank,20)
Global Sample%=PeekInt(infobank,24)
Global FileNameAddress%=PeekInt(infobank,28)


Thx gabriel :) Can anyone else help me w/ displaying the actual text OF infobank? Such as frequency? :)

~DS~

Ok, this plays. But why is it still returning 0 for frequency?

;BassInfo

Global FBassHandle
Global DropPath

Global DropFile$

Graphics3D 800, 600, 0, 2

Local infobank = CreateBank (32) ; DON'T RANDOMLY GUESS THE SIZE OF THE BANK. RESEARCH THE CALL AND FIND OUT HOW BIG THE DATA IS
; GOING TO BE. IN THIS CASE, IT APPEARS TO BE 8 INTEGERS. EACH INTEGER IS 4 BYTES, AND THAT'S 32 BYTES TOTAL.

Global Frequency%=PeekInt(infobank,0)
Global Channels%=PeekInt(infobank,4)
Global Flags%=PeekInt(infobank,8)
Global CType=PeekInt(infobank,12)
Global OriginalRes%=PeekInt(infobank,16)
Global Plugin%=PeekInt(infobank,20)
Global Sample%=PeekInt(infobank,24)
Global FileNameAddress%=PeekInt(infobank,28)

Local HWND=SystemProperty("AppHWND")

dp_Init(HWND)

;Includes
Include "bass.bb"

If BASS_Init(-1,44100,0,0,BASS_NULL)<>1 Then RuntimeError "Sound not ready":End

dp_AcceptFiles(1)

dp_RequestFiles("*.mp3|*.mp3;*.mp3")

			DropPath=dp_RequestedPath()
			DropQuant=dp_RequestedFileCount()
			
			;Delete old files
			If DragDrop=1 Then
				If DropQuant>0 Then
					TrackPos=0
					TrackAnz=0
					BASS_ChannelStop(FBassHandle)
				End If
			End If
			
			For DropCount=0 To DropQuant-1
				DropFile$=dp_RequestedPath()+""+dp_RequestedFile(DropFile$)
			Next

FBassHandle=BASS_StreamCreateFile(0,DropFile$,0,0,BASS_MUSIC_FLOAT)

BASS_ChannelGetInfo(FBassHandle,infobank)
BASS_ChannelPlay(FBassHandle,BASS_TRUE)

While Not KeyHit(1)

If DropFile<>""
Text 10, 10, "Song:"+DropFile

Text 10, 30, "infobank:"+Frequency%

Else

Text 10, 10, "Song not loaded into memory"

EndIf

UpdateWorld
RenderWorld

Flip

Wend


Gabriel, where EXACTLY can you find the data for the infobank peekint() ? I tried everywhere. to no avail..

You're reading the contents of the bank before you do anything with it, so of course it's empty. Move all the infobank code to a point after the call to BASS_ChannelGetInfo. And move the call to BASS_ChannelGetInfo after the call to BASS_ChannelPlay. You're asking for channel info on a channel you're not even playing.

You can EXACTLY find the data for the infobank in the bass.chm help file which comes with both Bass and Blitz Bass Studio. Specifically, if you look up the BASS_ChannelGetInfo function, which is the one you're trying to wrap, you'll see that the second parameter is a struct called

BASS_CHANNELINFO

If you click on that, you get the definition of that struct, which is as follows :

typedef struct {
    DWORD freq;
    DWORD chans;
    DWORD flags;
    DWORD ctype;
    DWORD origres;
    HPLUGIN plugin;
} BASS_CHANNELINFO;



I'm assuming that this is built on an old version of BASS, because the docs I have include two extra parameters in this.