|
Hello everyone.
I'm trying to properly read an id3v2 tag.
I've been trying for days now to figure it out but I cant seem to get it right.
here is what i have so far:
<br />
#include <iostream><br />
#include <string><br />
#include <fstream><br />
<br />
int main(int argc, char * argv[])<br />
{<br />
if (argc != 2) {<br />
cout<<"usage: id3v2 filename.mp3\n";<br />
exit(0);<br />
}<br />
<br />
ifstream in;<br />
in.open(argv[1]);<br />
<br />
char header[10];<br />
in.read(header,10);<br />
header[10] = '\0';<br />
<br />
if(header[0] == 'I' && header[1] == 'D' && header[2] == '3'){<br />
int hSize = ((header[3] & 127) << 21) |<br />
((header[4] & 127) << 14) |<br />
((header[5] & 127) << 7) |<br />
(header[6] & 127);<br />
<br />
int versionMajor, versionMinor;<br />
versionMajor = header[3];<br />
versionMinor = header[4];<br />
<br />
bool unsynchronisation,compression,experimental,extended,footer;<br />
unsynchronisation = false;<br />
compression = false;<br />
experimental = false;<br />
extended = false;<br />
footer = false;<br />
<br />
switch(versionMajor){<br />
case 2:<br />
unsynchronisation = (bool)(header[5] & 0x80);
compression = (bool)(header[5] & 0x40);
break;<br />
<br />
case 3:<br />
unsynchronisation = (bool)(header[5] & 0x80);
extended = (bool)(header[5] & 0x40);
experimental = (bool)(header[5] & 0x20);
break;<br />
<br />
case 4:<br />
unsynchronisation = (bool)(header[5] & 0x80);
extended = (bool)(header[5] & 0x40);
experimental = (bool)(header[5] & 0x20);
footer = (bool)(header[5] & 0x10);
break;<br />
}<br />
<br />
int sizeOfFrames;<br />
sizeOfFrames = hSize - 10;
<br />
<br />
cout<<"sizeOfFrames="<<sizeOfFrames<<endl;<br />
cout<<"\n\n";<br />
<br />
while(sizeOfFrames > 0){<br />
char frameId[4];<br />
char frameData[6];<br />
int frameSize;<br />
<br />
in.read(frameId,4);
in.read(frameData,6);
<br />
frameId[4] = '\0';
frameData[6] = '\0';
<br />
frameSize = ((frameData[0] & 127) << 21) |<br />
((frameData[1] & 127) << 14) |<br />
((frameData[2] & 127) << 7) |<br />
(frameData[3] & 127);<br />
<br />
if((frameSize > 0) && (frameSize < sizeOfFrames)){<br />
<br />
char tagInfo[frameSize];<br />
in.read(tagInfo,frameSize);<br />
tagInfo[frameSize] = '\0';
<br />
cout<<"frameId="<<frameId<<"\n";<br />
cout<<"frameSize="<<frameSize<<"\n";<br />
cout<<"tagInfo=";<br />
for(int x=0;x<sizeof(tagInfo);x++)<br />
cout<<tagInfo[x];
cout<<"\n\n";<br />
<br />
}<br />
sizeOfFrames -= frameSize;<br />
}<br />
if(versionMajor == 2){<br />
;
}<br />
}<br />
system("pause");<br />
return 0;<br />
}<br />
Sometimes it will read a bunch of garbage in from the file and print out
unexpected results, and other times it reads the id3 tag just fine.
for example: i used winamp to modify the id3v2 tag of one of my mp3 files adding the year. Then i ran this code again and it produced the unexpected results. A different mp3 file already had the year in its id3v2 tag, and when i ran this code, the program read the id3 tag just fine.
I'm almost sure that the frames have to be read differently depending on which version the tag is. I'm not sure if thats the problem or how to go about doing that.
I found someone else's code from another website that i have been trying to go off of to figure this out.
you can find it here:
http://tebl.homelinux.com/projects.php
just scroll down and click on "ID3V2"
and then click on "id3v2.c"
(sorry i cant give a direct link)
I compiled and ran the code from this website, and it reads the id3 tags for mp3 files just fine!!
So this just adds to my frustration.. I have someone else's code in front of me that works, and i still cant figure this out writing it on my own.
one thing though, i want to use fstream to do this because im most comfortable with it, and i dont want to use any structures or classes.
Just trying to write it flat and easy until i can understand everything.
Could anyone help me with the problems in my code?
I cant seem to figure out what im doing wrong.
Thanks for your time.
|
|
|
|
|
ifstream in;
in.open(argv[1], ios::in | ios::binary);
That's the first thing is saw.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
thanks, i forgot that flag. That helped a little bit. The problem is when i get the frame size sometimes it is incorrect. Or my loop is setup wrong?
This is how im determining the size of each frame of the id3 tag.
int frameSize = ((frameData[0] & 127) << 21) |
((frameData[1] & 127) << 14) |
((frameData[2] & 127) << 7) |
(frameData[3] & 127);
I got this code from another program and dont really understand it very much.
like ((frameData[0] & 127) why 127? and then followed by << 21 why 21?
how were these numbers were pulled out of the hat?
is this correct in determining the frame size?
|
|
|
|
|
Hi Dears,
I read application that use two view , first with GDI+ and Second with OpenGL.
Is there any conflict between these ?
and Can i do that ?
Best Regards,
|
|
|
|
|
|
Hi Dears,
I wanna know , how i can access serial and parallel? and if i start to do that
with subject i should learn.
Best Regards,
|
|
|
|
|
mostafa_pasha wrote:
how i can access serial and parallel?
CreateFile()
mostafa_pasha wrote:
with subject i should learn.
I don't understand the question. Developing applications that use communication mechanisms generally requires a broad range of topics.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Hello Friends,
This time I got another question for you.
In the Settings, we have got two options either we can go for Debug mode or Release Mode.
What are the main differences between the Debug Mode and the Release Mode? Which mode we have to choose?
Thank you
Bye friends.
|
|
|
|
|
DEBUG mode adds information to the build for debugging purposes. RELEASE mode does not contain this information and is therefore much smaller and likely faster as well.
Actually there is quite a bit more to it than that. You would have to do some studying on the subject to become versed in it.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Comparing Debug and Release Mode
Debug mode compiles and links the code such that it can be run with the debugger. This lets you single step through the source code, set breakpoints, and examine variables during execution. Release mode code cannot be run under the debugger with full source code information available.
Compiling for debug turns off all optimizations in order to make debugging easier. This makes the code slower and much larger than release mode. When you compile in release mode, you can choose the optimizations that the compiler performs. Optimizations can generate faster code, or make the resulting .EXE smaller, or any of a wide variety of choices for performance tuning.
Debug code cannot be distributed, because it runs with the debug libraries for the 'C' runtime, MFC, etc. The debug libraries may not be distributed, since they are licensed as part of the development package. Release mode code runs with the release libraries, which you are allowed to distribute.
The debug versions of the runtime libraries behave differently from the release versions. The heap functions (new , delete , malloc , free , and so on) change how they allocate memory so that they can detect when you have overrun allocated buffers or make other allocation errors. Functions in the libraries tend to check their arguments and ASSERT when you've supplied an invalid value. These error checks are not used in the release libraries, which means these errors can go undetected until the program crashes.
Which Should I Use?
Typical practice is to start out developing and testing your program in debug mode. When you think you've got the program working correctly, and you have tested it thoroughly, compile it for release and test it again. When your program is compiled for release, it may behave somewhat differently from the debug version. It will probably run faster. It will probably use less memory than the debug version. If the program is multithreaded, you may see threading problems that you did not see in the debug version, due to the timing changes.
Software Zen: delete this;
|
|
|
|
|
how to get #322776(Dialog) class 's handle
d
|
|
|
|
|
How to get #322770(Dialog) class 's handle
d
|
|
|
|
|
I think you mean #32770 .
You can use FindWindow() to find the window handle of a window with the dialog class, but you will need more information to find the window you are after as there is typically many dialogs open at the same time.
HWND hWnd = FindWindow(_T("#32770"), _T("Dialog Caption"));
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
That depends on if it's your own dialog, or someon eelses. Most likely, it's from another app, right? Then you might want to check FindWindow and - as you might not have the caption - EnumWindows and EnumChildWindows .
|
|
|
|
|
Dear viewers,
I want to create a window in mfc that will contain no menubar,titlebar etc. just a window with borders so that
it can be used to show images or something appropriate
in this case. so is there any way out? plz help me.
|
|
|
|
|
Leave off the WS_CAPTION style when you create the window.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
here a small code you put in CFrameWnd derived class Constructor
Create(0//class name,"helloo alok"//Windows caption,don't woory it not going to show up,WS_BORDER|WS_VISIBLE);
this code will solve your problem
-----------------------------
"I Think It will Work"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
I decided to hack up my own tab control functionality. Instead of having a "simple" tab control, I thought I'd make a tab control a'la .NET/Winforms. By that I mean I have a method called AddSheet(title, hWndSheet) . The tab control will then itself keep track of what sheet to show, etc. I believe there is such functionality in MFC already, but since I'm not using MFC, that's not an option.
So, onto the specifics of the problem.
When all the tabs can be displayed inside the client area, all is fine and dandy. But as soon as the area becomes too small, and it displays the scroll buttons in the top right corner, my children are clipped. The weirdest part is that only buttons are affected by the clipping. I've put list controls in there, as well as my own controls. If I turn off theming (Windows Classic Style), no clipping is done.
As I don't have a good way to put up a screenshot, I'll do my best to describe the clipping by using words and ASCII art.
Here's the tab control:
+---------------------------------------+
| Tab 1 | Tab 2 | Tab 3 | Tab 4 | < | > | <- Here's the two scroll buttons
+-------+-------------------------------+
|+-------------------------------xxxxxxx|
|| xxxxxxx|
|| A Button xxxxxxx| <- x marks the clipped area
|| xxxxxxx|
|+-------------------------------xxxxxxx|
+---------------------------------------+
The clipped area is everything to the right of the scroll buttons left edge. The clipped area is drawn with the tab control background, and not some grey left over color from background erasing.
I have fiddled with sibling & children clip styles on the tab control, but none of that has helped.
Possibly worth knowing is that I have subclassed the tab control. I override WM_SIZE where I resize the child controls (using AdjustArect and all - it does work which one can see easily when the darn thing isn't clipping my buttons). I have not overridden any painting message, so I don't think I'm doing the clipping explicitly.
Any clues? I am perplexed.
--
Ich bin Joachim von Hassel, und ich bin Pilot der Bundeswehr.
Welle: Erdball - F104-G Starfighter
|
|
|
|
|
Jörgen Sigvardsson wrote:
The tab control will then itself keep track of what sheet to show, etc. I believe there is such functionality in MFC already, but since I'm not using MFC, that's not an option.
I believe you are talking about MFC's CPropertySheet and CPropertyPage classes. These classes are a wrapper around the WIN32 propertysheet functions.
Check MSDN for:
PropertySheet()
PROPSHEETHEADER
PROPSHEETPAGE
PSM_* messages
PropSheet_* macros (PSM_* wrapper macros)
PropSheetProc()
PropSheetPageProc()
etc.
While MFC is definitely easier to use, using these ready made WIN32 functions has got to be easier than rolling your own. But then again, maybe you are a glutton for punishment.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
PJ Arends wrote:
While MFC is definitely easier to use, using these ready made WIN32 functions has got to be easier than rolling your own. But then again, maybe you are a glutton for punishment.
As I'm currently reinstalling everything at home (including Windows), I don't have MSDN yet. However, aren't these functions for property page dialogs and the likes? The tab controls are just building blocks in a bigger picture for me, and I'd like to stay away from dialog resources, for technical and aestethical reasons.
Anyway, I think I understand why the buttons behave like they do on tab controls. Buttons use their parents DC to render themselves. I suspect the tab control does some weird clipping when it's themed, resulting in the clipped button. I believe I have one of three options:
1) Hack my way through tab control & buttons and back again: Mission Impossible
2) Write my own button class (silly, but quite doable)
3) Create a host window which all child controls lie on.
I think 3) is the smartest choice. It will assure that my DC isn't screwed with, and I believe this is how it's generally done. However, I think I will make the host window transparent, so that the tab control background shines through. Doesn't do much on a Win2k machine, but on an XP machine, the gradient will look pretty nice.
I will however have a look at the functions you mentioned, as soon as I've got everything installed again (tomorrow if I'm lucky ) Thanks for the tip, much appreciated!
--
Ich bin Joachim von Hassel, und ich bin Pilot der Bundeswehr.
Welle: Erdball - F104-G Starfighter
|
|
|
|
|
Jörgen Sigvardsson wrote:
aren't these functions for property page dialogs and the likes?
Yes they are.
But you could still use them, you would just have to create an empty (as in no controls) DLGTEMPLATE structure in memory, and use that to create the pages. Then dynamically create all your controls on the page later. I am sure there are many was to skin that cat and you will find the best one for you.
Have fun!
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
can we have a screenshot?
I have an ActiveX that basically does the same, but doesn`t exhibit the problem
we are here to help each other get through this thing, whatever it is Vonnegut jr.
sighist || Agile Programming | doxygen
|
|
|
|
|
I can't give you a screenshot I'm afraid. 1) I'm not at the office, 2) I don't have a good server to put it on.
Besides, I think I know a workaround. It's the damn button's fault; it uses its parent's DC, which is clipped somehow by the scrollbuttons in the tab control. If I put a window which uses its own DC on the tab control, which hosts the child controls, it should work. And that is probably the "trick" too. Almost all tab controls I've seen, has all of its children on a dialog child control. A dialog child control has its own DC, and is thus not affected by peculiarities of the tab control.
--
Ich bin Joachim von Hassel, und ich bin Pilot der Bundeswehr.
Welle: Erdball - F104-G Starfighter
|
|
|
|
|
I've managed to add a button to the IE main toolbar using the extension configuration section in the registry and I've implemented an IOleCommandTarget COM object to handle the button click.
The question is, how can I get the co-ordinates of my button out of IE so that I can display my menu of options neatly aligned below it? Any help or pointers to info would be gratefully appreciated!
|
|
|
|
|
Hi,
I am using the string table to hold all the UI string I use in my application. However I cannot seem load them into my program. this is the sequence i use:
CString test;
int y;
DWORD Failure;
y = test.LoadString(IDS_APN);
Whenever i call the GetLastError() commnad, the error code indicates the string is not present, even though it is present in both the string table editor and the Resource.h file.
What am i doing wrong?
Thanks in advance,
femi.
|
|
|
|
|