ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
...
Learn to build and troubleshoot your code incrementally, not in large blocks.
This is sage advice. I'm a beginner myself and whenever I have been tasked with a programming exercise I would write the whole thing out in one go and more often then not I would be hit with multiple errors, warnings, and then when it did finally compile I would spend 15 minutes, 20 minutes, sometimes over an hour tracking down a bug. This was not only time consuming and frustrating but was a real blow to my self esteem. Once I realized I should be stripping down what is asked of me to the bare essentials, getting it to compile, then building on top of that, programming became a totally different and better experience. More enjoyable, and much less frustrating. Also having a pen and pad of paper with me to sketch out the design of the program and work out details really streamlines the process.
Everybody wants to be a star.
The Olympic Gold Medal winner.
The Oscar winning actor.
The Nobel Prize winning scientist.
The social media billionaire.
There's nothing wrong with aspiring to be solidly competent in any field you choose. A doctor who makes sick people well. A brickmason who builds a durable wall. A carpenter who builds a sturdy shed. A programmer who produces (almost) bug-free code.
You won't be the next Bill Gates or Steve Jobs or Linus Torvalds or Mark Zuckerberg. Neither will I. You don't have to be a star. You can be a contributor.
The fundamental goal of every human being: make this world a bit better when you leave it than it was when you entered it. Be honest. Be decent. Follow the Golden Rule. Do all that, and have some fun along the way.
Daniel B. Martin
.
My personal coding goals (for non work purposes) is honestly just to have my own OS (like a Linux distro) and slowly over time code my own kernal. The kernal is obviously years from now, but putting together the OS is actually quiet easy with my friend helping. My dream job is doing firmware and kernal coding, I know those days are far away, but I just feel like I should know more now than I do sometimes.
No one else my age (in my area like school and stuff) doesn't do anything computers at all.
Join the crowd. I'm by no means a professional programmer but I do have several apps to my name. And if it helps I started with C at about your age(not long ago). I learned with a book and later the internet helped answer questions. However it takes time, and I can tell you that you ARE on the right track, stick to it. You have an app to work on and a idea on how it should work, this is half of the work.
I used to avoid libraries as well. Now I can't do without them, its extremely hard to write any gui app without libraries. Under Windows statically linked libraries is a huge bloat problem. I haven't noticed it on Linux. If you link shared, there really no bloat.
Apart from the last few fields this looks suspiciously like a ID3v1 structure, which is a fixed-length one, total of exactly 128 bytes and is - when present - located at the END of the mp3 file. It is designated with a fixed string TAG (which is present 128 bytes before the end of the file).
An ID3V2 is located at the beginning of the file, starts with the string ID3 and after that come pairs of keywords and values, in ANY order and everything may be present or not.
Strings like i.e. the song title (keyword TIT2) are variable length, so NOT restricted to 30 chars. This is a hexdump from the id3v2 from a random mp3 file in my collection:
TIT2 (Title/songname/content description)
TPE1 (Lead performer(s)/Soloist(s))
TPE2 (Band/orchestra/accompaniment)
TALB (Album/Movie/Show title)
TYER (Year)
TCON (Content type)
TENC (Encoded by)
TRCK (Track number/Position in set)
TPOS (Part of a set)
APIC (Attached picture)
JFIF starts off a jpeg file
Descriptions of these fields come out of the id3v2 program and ANY field is optional, i.e. in this case the TPE2 field could have been omitted as it isn't different from the TPE1 one.
Note too that there are no comment or lyrics fields present.
There are binary values inbetween the keyword and the (text) value, as to designate its length etc.
I think you best look AT the source code of the id3v2 program for ideas how to process id3 tags, you can get that at sourceforge.net/projects/id3v2/.
You will need the id3lib code too to compile it, at sourceforge.net/projects/id3lib/.
I recommend too that you take a look at the wikipedia page for id3 tags: en.wikipedia.org/wiki/ID3 to learn how those tags are built-up.
Last edited by ehartman; 06-20-2019 at 11:22 PM.
Reason: Addition about missing fields
Apart from the last few fields this looks suspiciously like a ID3v1 structure, which is a fixed-length one, total of exactly 128 bytes and is - when present - located at the END of the mp3 file. It is designated with a fixed string TAG (which is present 128 bytes before the end of the file).
An ID3V2 is located at the beginning of the file, starts with the string ID3 and after that come pairs of keywords and values, in ANY order and everything may be present or not.
Strings like i.e. the song title (keyword TIT2) are variable length, so NOT restricted to 30 chars. This is a hexdump from the id3v2 from a random mp3 file in my collection:
Descriptions of these fields come out of the id3v2 program and ANY field is optional, i.e. in this case the TPE2 field could have been omitted as it isn't different from the TPE1 one.
There are binary values inbetween the keyword and the (text) value, as to designate its length etc.
I think you best look AT the source code of the id3v2 program for ideas how to process id3 tags, you can get that at sourceforge.net/projects/id3v2/.
You will need the id3lib code too to compile it, at sourceforge.net/projects/id3lib/.
I recommend too that you take a look at the wikipedia page for id3 tags: en.wikipedia.org/wiki/ID3 to learn how those tags are built-up.
Yeah, I was looking over my code and after testing fseek that that is it, I'll probably find a way to loop through the file and print the things as I finnd them.
Yeah, I was looking over my code and after testing fseek that that is it, I'll probably find a way to loop through the file and print the things as I finnd them.
Here's a problem. You should not be reverse engineering a file which has a structure. One which you were given a wiki to, and also observed the very simple hex dump example. Just inspect the file you have, verify it makes sense using the wiki, then alter your code to print out the correct information.
As an idea, if that structure is typically no larger than some size, then read a chunk large enough and parse through that to find each portion of the header.
Join the crowd. I'm by no means a professional programmer but I do have several apps to my name. And if it helps I started with C at about your age(not long ago). I learned with a book and later the internet helped answer questions. However it takes time, and I can tell you that you ARE on the right track, stick to it. You have an app to work on and a idea on how it should work, this is half of the work.
I used to avoid libraries as well. Now I can't do without them, its extremely hard to write any gui app without libraries. Under Windows statically linked libraries is a huge bloat problem. I haven't noticed it on Linux. If you link shared, there really no bloat.
P.S.
If you're interested in writing an opsys, check the link in my signature.
Hey Void Linux! I love Void, well I love and don't love it; the work they do with respect to both BSD and Linux is actually a big inspiration on my system (PLUS runit is the best init since daemontools!!!!!!). I am reading the docs, but I think I may ask my teacher about this as well; one thing I often struggle with is understanding the docs and making code from them. My teacher has been a C coder since the 80s/90s (I believe 80s) so he knows C well. It's just hard when I work at something for a bit and get no where, but I want to do this no matter how long it takes. I shall know this code in and out by the time I am done, I don't want to rely on kid3 anymore
Hey Void Linux! I love Void, well I love and don't love it; the work they do with respect to both BSD and Linux is actually a big inspiration on my system (PLUS runit is the best init since daemontools!!!!!!). I am reading the docs, but I think I may ask my teacher about this as well; one thing I often struggle with is understanding the docs and making code from them. My teacher has been a C coder since the 80s/90s (I believe 80s) so he knows C well. It's just hard when I work at something for a bit and get no where, but I want to do this no matter how long it takes. I shall know this code in and out by the time I am done, I don't want to rely on kid3 anymore
/*Off Topic
Yup I really like Void. Another question: have you built Linux From Scratch yet? I owe a lot of my Linux/OS knowledge to that experience.*/
I've already spent days(or weeks) debugging and finding extremely simple bugs, the harder ones are usually easier to find Invest in some patience, it'll pay for itself in no time
/*Off Topic
Yup I really like Void. Another question: have you built Linux From Scratch yet? I owe a lot of my Linux/OS knowledge.*/
I've already spent days(or weeks) debugging and finding extremely simple bugs, the harder ones are usually easier to find Invest in some patience, it'll pay for itself in no time
I did try LFS after Gentoo. I didn't like Gentoo, because I couldn't get gcc and rsync off w/o breaking portage. I did a lot of hardening and beloating on gentoo; but it got to the point where I may as well have forked it. Then I did LFS, I didn't like LFS because it was bloated (yes yes it was for me) so I left it. I then went to Alpine, ended up writing some docs for them; but didn't like busybox or OpenRC so I decided to build my own system with a friend.
/*Off Topic
Yup I really like Void. Another question: have you built Linux From Scratch yet? I owe a lot of my Linux/OS knowledge.*/
I've already spent days(or weeks) debugging and finding extremely simple bugs, the harder ones are usually easier to find Invest in some patience, it'll pay for itself in no time
Well id3 might be a bust for now, but at least I am making progress on my package manager
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.