Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: writing an MPC header reader (Read 4564 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

writing an MPC header reader

Hi all,

Does anyone know of any C++ libraries / wrappers that return basic info about an MPC file, ie. bitrate, length, frequency, etc...? I could not find one, so I figured I had to write one myself using libmusepack, but kept running into problems.

Not knowing where to start, I figured I'd take the sample.cpp that comes with libmusepack, throw out the decoder portion, and get info using the mpc_streaminfo struct (members Bitrate, TotalFileLength, etc..)

First, the compiler complained that it couldn't find the config_types.h file. I only found a config_types.h.in (what on earth is an .in file??) but figured that this would be it, so changed the extension to .h.

Then it complained of the @ in statements like
typedef @SIZE16@ mpc_int16_t;
Is this valid C syntax? Not having much idea what was going on here, I removed the @'s.

Then the compiler complained about something else in another file and so on and so on.. not getting me anywhere.

Can anyone be so kind as to point me in the right direction with these newbie questions? I don't think I'll get anywhere on my own with my current knowlege. I'm using VS7, by the way.

Thanks for any help!

writing an MPC header reader

Reply #1
You are supposed to run 'configure' before. It will convert config_types.h.in into a proper file with appropriate types for you system.
As you use VS7, you cannot use autotools(configure stuff); So you are forced to create your own config_types.h.
I suggest the following for msvc

typedef __int16 mpc_int16_t;
typedef unsigned __int16 mpc_uint16_t;
typedef __int32 mpc_int32_t;
typedef unsigned __int32 mpc_uint32_t;
typedef __int64 mpc_int64_t;


Then you can use only mpc_streaminfo to get back informations you need about the files.and abviously, mpc_reader too
It's a 'Jump to Conclusions Mat'. You see, you have this mat, with different CONCLUSIONS written on it that you could JUMP TO.

writing an MPC header reader

Reply #2
You should really compile and install libmusepack before you try to write applications that use it.

 

writing an MPC header reader

Reply #3
Thanks for your input!
Lefungus, I did not get your suggestion completely, but presume that you meant this: because I'm using VS7, I have no choice but to rename the config_types.h.in file to config_types.h and replace the typedef statements with those you suggested.
I did this, but then the linker complained that it could not find the implementations of functions such as mpc_decoder_decode. I don't understand why there aren't any .lib files to direct the linker to.. Why is this? Anyhow, I found that the function was inside mpc_decoder.c, so as a quick fix, I just put all the files in the src folder into my project.

But then I got errors like "expect '(' to follow 'inline' at line"
Code: [Select]
 static inline mpc_uint32_t swap32(mpc_uint32_t val) {

I couldn't for the life of me figure out why, because the above looked like valid C syntax to me. I think the compiler had trouble with the mpc_uint32_t type, even though it had been defined in config_types.h previously...

Just so I could move forward, I took out the static keyword, which removed that error, but then some other error popped up in another file (compiler did not recognize mpc_uint32_t type again, even after I put a typedef statement right above the line..) and so on and so forth.

Sorry, I realize this is becoming more and more of a C syntax questionnaire, but I'm just not finding this very straightforward, with my limited knowledge on programming.

kuniklo, I agree with what you suggested, but forgive my ignorance, what do you exactly mean by "compiling and installing libmusepack"? Do I just create a blank project, dump all the .h and .c files into the project and try to compile..?

I really appreciate your input! My programming experience is yet very limited and I appreciate any help I can get along the way.