get bitrate

Blitz3D Forums/Blitz3D Programming/get bitrate

Guy Fawkes(Posted 2009) [#1]
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!


Abrexxes(Posted 2009) [#2]
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


Guy Fawkes(Posted 2009) [#3]
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~


Abrexxes(Posted 2009) [#4]
http://www.un4seen.com/forum/?action=profile;u=4468;sa=showPosts ;)


Guy Fawkes(Posted 2009) [#5]
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~


Guy Fawkes(Posted 2009) [#6]
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~


Gabriel(Posted 2009) [#7]
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.


Guy Fawkes(Posted 2009) [#8]
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.


Gabriel(Posted 2009) [#9]
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.


Guy Fawkes(Posted 2009) [#10]
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~


Gabriel(Posted 2009) [#11]
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.


Guy Fawkes(Posted 2009) [#12]
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().



Thanks for helping! :)

~DS~


Gabriel(Posted 2009) [#13]
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)



Guy Fawkes(Posted 2009) [#14]
Thx gabriel :) Can anyone else help me w/ displaying the actual text OF infobank? Such as frequency? :)

~DS~


Guy Fawkes(Posted 2009) [#15]
Ok, this plays. But why is it still returning 0 for frequency?




Guy Fawkes(Posted 2009) [#16]
Gabriel, where EXACTLY can you find the data for the infobank peekint() ? I tried everywhere. to no avail..


Gabriel(Posted 2009) [#17]
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.


Guy Fawkes(Posted 2009) [#18]
Right. now what site can i see that has the amount of bytes for freq, chans, etc?


Gabriel(Posted 2009) [#19]
You can find out what a DWORD is using Google, and you can find out what a HPLUGIN is using the Bass documentation and headers.


Ginger Tea(Posted 2009) [#20]
Right. now what site can i see that has the amount of bytes for freq, chans, etc?


if you mean header files just google the file format with "wav header file"
and repeat for wma mp3 ogg etc

but i thought this lib dealt with that for you, or am i just misreading the question?


Guy Fawkes(Posted 2009) [#21]
Gabriel, is there ANY way you could whip up an example w/o compiling cuz i know it wont work for u, in which u can use BASS_GetChannelInfo() with this data, to get the bitrate?



Thanks! :)

~DS~


Guy Fawkes(Posted 2009) [#22]
Is this correct?



Why does this return 0?




_PJ_(Posted 2009) [#23]
I was looking for something else and ca,me across this:

http://www.audiogenie.de/en/index.htm


It might be helpful.
Also, I learned that the given bitrate, even static ones, are not absolute with regards to , but represents the TOTAL SUM of bitrates (or bitrate tolerances for vbr) across ALL channels.

For example, a stereo file may be represented as 128kbps but in actuality, it is 2 channels (left & right) each of 64kbps.


Guy Fawkes(Posted 2009) [#24]
NICE! :D

I will check it out a bit later yo :)

Workin on my rpg right now :D

~DS~