LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-20-2019, 05:32 PM   #16
Mechanikx
Member
 
Registered: Jul 2018
Location: Canada
Distribution: Slackware
Posts: 150

Rep: Reputation: 111Reputation: 111

Quote:
Originally Posted by astrogeek View Post
...
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.
 
2 members found this post helpful.
Old 06-20-2019, 05:33 PM   #17
FOSSilized_Daemon
Member
 
Registered: Mar 2019
Posts: 188

Original Poster
Rep: Reputation: 13
Quote:
Originally Posted by danielbmartin View Post
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.
 
Old 06-20-2019, 09:26 PM   #18
Mill J
Member
 
Registered: Feb 2017
Location: 127.0.0.1 Sweet 127.0.0.1
Distribution: Void, MX, Haiku, Puppy and many others
Posts: 930
Blog Entries: 2

Rep: Reputation: 389Reputation: 389Reputation: 389Reputation: 389
Quote:
Originally Posted by FOSSilized_Daemon View Post
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.



P.S.

If you're interested in writing an opsys, check the link in my signature.
https://www.linuxquestions.org/quest...systems-37776/

Last edited by Mill J; 06-22-2019 at 07:31 AM.
 
1 members found this post helpful.
Old 06-20-2019, 10:14 PM   #19
ehartman
Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 672

Rep: Reputation: 317Reputation: 317Reputation: 317Reputation: 317
Quote:
Originally Posted by FOSSilized_Daemon View Post
Code:
	typedef struct {
		char TAG[3];
		char title[30];

		char artist[30];
		char album[30];

		char comment[30];
		short date;

		short track_number;
		char genre[30];

		char album_artist[30];
		char lyrics[30];

		char cover[30];
	}id3;
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:
Code:
 $ hexdump -C The_Civil_Wars-Sour_Times.mp3
00000000  49 44 33 03 00 00 00 07  07 33 54 49 54 32 00 00  |ID3......3TIT2..|
00000010  00 0b 00 00 00 53 6f 75  72 20 54 69 6d 65 73 54  |.....Sour TimesT|
00000020  50 45 31 00 00 00 0f 00  00 00 54 68 65 20 43 69  |PE1.......The Ci|
00000030  76 69 6c 20 57 61 72 73  54 50 45 32 00 00 00 0f  |vil WarsTPE2....|
00000040  00 00 00 54 68 65 20 43  69 76 69 6c 20 57 61 72  |...The Civil War|
00000050  73 54 41 4c 42 00 00 00  16 00 00 00 42 65 74 77  |sTALB.......Betw|
00000060  65 65 6e 20 74 68 65 20  42 61 72 73 20 28 45 50  |een the Bars (EP|
00000070  29 54 59 45 52 00 00 00  15 00 00 00 32 30 31 34  |)TYER.......2014|
00000080  2d 30 32 2d 30 37 54 30  38 3a 30 30 3a 30 30 5a  |-02-07T08:00:00Z|
00000090  54 43 4f 4e 00 00 00 0c  00 00 00 41 6c 74 65 72  |TCON.......Alter|
000000a0  6e 61 74 69 76 65 54 45  4e 43 00 00 00 08 40 00  |nativeTENC....@.|
000000b0  00 6c 33 65 6e 64 69 6b  54 52 43 4b 00 00 00 04  |.l3endikTRCK....|
000000c0  00 00 00 31 2f 34 54 50  4f 53 00 00 00 04 00 00  |...1/4TPOS......|
000000d0  00 31 2f 31 41 50 49 43  00 01 c2 df 00 00 00 69  |.1/1APIC.......i|
000000e0  6d 61 67 65 2f 6a 70 65  67 00 03 00 ff d8 ff e0  |mage/jpeg.......|
000000f0  00 10 4a 46 49 46 00 01  01 01 00 48 00 48 00 00  |..JFIF.....H.H..|
(rest of the dump skipped)
The keywords you see here are
Quote:
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
 
1 members found this post helpful.
Old 06-20-2019, 11:07 PM   #20
FOSSilized_Daemon
Member
 
Registered: Mar 2019
Posts: 188

Original Poster
Rep: Reputation: 13
Quote:
Originally Posted by ehartman View Post
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:
Code:
 $ hexdump -C The_Civil_Wars-Sour_Times.mp3
00000000  49 44 33 03 00 00 00 07  07 33 54 49 54 32 00 00  |ID3......3TIT2..|
00000010  00 0b 00 00 00 53 6f 75  72 20 54 69 6d 65 73 54  |.....Sour TimesT|
00000020  50 45 31 00 00 00 0f 00  00 00 54 68 65 20 43 69  |PE1.......The Ci|
00000030  76 69 6c 20 57 61 72 73  54 50 45 32 00 00 00 0f  |vil WarsTPE2....|
00000040  00 00 00 54 68 65 20 43  69 76 69 6c 20 57 61 72  |...The Civil War|
00000050  73 54 41 4c 42 00 00 00  16 00 00 00 42 65 74 77  |sTALB.......Betw|
00000060  65 65 6e 20 74 68 65 20  42 61 72 73 20 28 45 50  |een the Bars (EP|
00000070  29 54 59 45 52 00 00 00  15 00 00 00 32 30 31 34  |)TYER.......2014|
00000080  2d 30 32 2d 30 37 54 30  38 3a 30 30 3a 30 30 5a  |-02-07T08:00:00Z|
00000090  54 43 4f 4e 00 00 00 0c  00 00 00 41 6c 74 65 72  |TCON.......Alter|
000000a0  6e 61 74 69 76 65 54 45  4e 43 00 00 00 08 40 00  |nativeTENC....@.|
000000b0  00 6c 33 65 6e 64 69 6b  54 52 43 4b 00 00 00 04  |.l3endikTRCK....|
000000c0  00 00 00 31 2f 34 54 50  4f 53 00 00 00 04 00 00  |...1/4TPOS......|
000000d0  00 31 2f 31 41 50 49 43  00 01 c2 df 00 00 00 69  |.1/1APIC.......i|
000000e0  6d 61 67 65 2f 6a 70 65  67 00 03 00 ff d8 ff e0  |mage/jpeg.......|
000000f0  00 10 4a 46 49 46 00 01  01 01 00 48 00 48 00 00  |..JFIF.....H.H..|
(rest of the dump skipped)
The keywords you see here are

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.
 
Old 06-21-2019, 06:03 AM   #21
rtmistler
Moderator
 
Registered: Mar 2011
Location: MA, USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 7,780
Blog Entries: 13

Rep: Reputation: 3273Reputation: 3273Reputation: 3273Reputation: 3273Reputation: 3273Reputation: 3273Reputation: 3273Reputation: 3273Reputation: 3273Reputation: 3273Reputation: 3273
Quote:
Originally Posted by FOSSilized_Daemon View Post
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.

Last edited by rtmistler; 06-21-2019 at 06:05 AM.
 
Old 06-21-2019, 11:48 AM   #22
FOSSilized_Daemon
Member
 
Registered: Mar 2019
Posts: 188

Original Poster
Rep: Reputation: 13
Quote:
Originally Posted by Mill J View Post
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
 
Old 06-21-2019, 12:46 PM   #23
Mill J
Member
 
Registered: Feb 2017
Location: 127.0.0.1 Sweet 127.0.0.1
Distribution: Void, MX, Haiku, Puppy and many others
Posts: 930
Blog Entries: 2

Rep: Reputation: 389Reputation: 389Reputation: 389Reputation: 389
Quote:
Originally Posted by FOSSilized_Daemon View Post
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

Last edited by Mill J; 06-22-2019 at 07:30 AM.
 
Old 06-21-2019, 01:08 PM   #24
FOSSilized_Daemon
Member
 
Registered: Mar 2019
Posts: 188

Original Poster
Rep: Reputation: 13
Quote:
Originally Posted by Mill J View Post
/*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.
 
Old 06-21-2019, 02:20 PM   #25
FOSSilized_Daemon
Member
 
Registered: Mar 2019
Posts: 188

Original Poster
Rep: Reputation: 13
Quote:
Originally Posted by Mill J View Post
/*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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
OCRAD returns gibberish EVERY time - is there a good HowTo? KimVette Linux - Software 18 08-29-2005 02:24 AM
xchm 0.9.6-1 displaying gibberish? nagromo Linux - Software 0 12-19-2004 04:43 PM
Apollo P-2200, apsfilter, and a bit of gibberish goofyheadedpunk Slackware 0 10-15-2004 05:15 PM
Console gibberish linmonkey Slackware 2 07-12-2004 09:14 AM
Canon BJC 210 SP prints gibberish!! blaze_wk Linux - Hardware 1 02-25-2004 02:02 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration