# Programming for Audio CD



## shuxuef (Apr 2, 2010)

Hi, there!

Being a newbie to both FreeBSD and programming (I have learnt C though), I am planning to write a programme that can play audio CD. My story is the following:

I have FreeBSD-release 8.0 installed on my HP compaq laptop. And I found that most of the CD players in the ports would not be able to play audio CDs on my machine. For example, cdcontrol is able to get the CD running, but without any sound; workman, cdplay, gnustep-cdplayer, xmcd, etc, would not work at all; xmms can work, but the sound is not good, plus, it doesn't display the title of the tracks; mplayer can play, but with very loud noise of the CD spinning; loud noise comes with anything using cdparanoia; 

Some of the experts here in the forum said that it's because my CD drive does not have cable connecting directly to the sound-card, or something like that; so I have to use digital extraction.  And I am guessing that is called CDDA extraction.  

Actually, I have found out the cdda2wav is able to extract the data and "echo" the sound to sound-card. So I used shell script, with cdcontrol and cdda2wav, to write a simple audio cd player.  But it's not a very satisfactory one.  

So I am wondering if there is any language that is suitable enough for me to write a audio-cd player; and of course, things like "standard library" could be used as well.  I tried python with pygame, only to find that pygame.cdrom.get_count() could not even recognize my CD drive. I tried to install pymedia, but somehow it could not be successfully installed. If any of you know how to install pymedia on FreeBSD-release 8.0, please let me know. 

And here I am, eagerly asking for your help and suggestion. I can go to read cdda2wav's source code of course, but I'd rather not do that, since that would require a lot of effort. Is there any programming language, library, tools I can use? 

Thanks for your attention and your help in advance!


----------



## richardpl (Apr 2, 2010)

mplayer supports configuring speed of drive.

Do your homework and read documentation and manual pages before asking obvious.


----------



## shuxuef (Apr 3, 2010)

richardpl said:
			
		

> mplayer supports configuring speed of drive.
> 
> Do your homework and read documentation and manual pages before asking obvious.



Richardpl, I strongly suggest you change your way of saying things.  I appreciate your first sentence; but the second one is really unnecessary. If a person is thinking of writing a new program, that usually means that either he's interested in the "writing" itself, or he's unsatisfied with the existing programmes; and in either case, chances are good that he's done an appropriate amount of reading.  Now, if you agree with what I am saying, then it means that you also agree that I am not asking obvious things; and if you don't, then it means that you agree that some things obvious to some people might not so obvious to the other; and that's why they need to ask. Sometimes, it would save them a lot of time if they ask.  I believe you don't have the obligation to answer every new post so that you'll get annoyed by trivial questions, do you?

About mplayer, actually the loud-noise issue was in release-7.2.  I didn't even bother to try it on Release-8.0, the reason is mainly that mplayer does not provide good navigation tools to allow one to play an arbitrary track. (!, @, ->, <-, Pageup, Pagedown don't work quite well). Originally on FreeBSD release-7.2, the noise was quite loud, with strong vibrating of the whole laptop; and it was always there no matter how you adjusted the speed (I did try to adjust the speed).  But after richardpl mentioned it, I found that in release-8.0, the loud-noise-and-vibrating problem is gone somehow. But still with no good navigation tools. 

Let me just emphasize that I am more interested in writing a new program. 


Thanks!


----------



## Lowell (Apr 3, 2010)

Nearly all programs that can play CDs are capable of doing digital extraction (I use multimedia/xmms and audio/amarok, but they are a bit heavyweight for just playing a CD).  If you're interested in writing your own, my advice would depend on *why* you want to do so.

For instance, if your interest is in gaining programming experience, my answer would be that you should use whatever language(s) and toolkit(s) will be most useful to you for your future plans, regardless of whether they are the ideal match to the current project.


----------



## richardpl (Apr 3, 2010)

shuxuef said:
			
		

> Richardpl, I strongly suggest you change your way of saying things.  I appreciate your first sentence; but the second one is really unnecessary. If a person is thinking of writing a new program, that usually means that either he's interested in the "writing" itself, or he's unsatisfied with the existing programmes; and in either case, chances are good that he's done an appropriate amount of reading.  Now, if you agree with what I am saying, then it means that you also agree that I am not asking obvious things; and if you don't, then it means that you agree that some things obvious to some people might not so obvious to the other; and that's why they need to ask. Sometimes, it would save them a lot of time if they ask.  I believe you don't have the obligation to answer every new post so that you'll get annoyed by trivial questions, do you?



No comment.



			
				shuxuef said:
			
		

> About mplayer, actually the loud-noise issue was in release-7.2.  I didn't even bother to try it on Release-8.0, the reason is mainly that mplayer does not provide good navigation tools to allow one to play an arbitrary track. (!, @, ->, <-, Pageup, Pagedown don't work quite well). Originally on FreeBSD release-7.2, the noise was quite loud, with strong vibrating of the whole laptop]
> 
> Have you tried smplayer? You could create similar fancy application like amarok (which is using gstreamer/libxine) just with using mplayer.
> 
> ...


I do not care. If you want to reinvent the wheel go ahead.

And BTW you are asking it in wrong forum.


----------



## shuxuef (Apr 3, 2010)

Lowell said:
			
		

> Nearly all programs that can play CDs are capable of doing digital extraction (I use multimedia/xmms and audio/amarok, but they are a bit heavyweight for just playing a CD).  If you're interested in writing your own, my advice would depend on *why* you want to do so.
> 
> For instance, if your interest is in gaining programming experience, my answer would be that you should use whatever language(s) and toolkit(s) will be most useful to you for your future plans, regardless of whether they are the ideal match to the current project.



I think I am just interested in picking up some programming language that is ideal for this particular purpose, writing a text-based CD player which is able to provide the user current playing position and track information, which also supports strong navigation (or file "seeking"?) interaction that would allow the user to play an arbitrary track, or to start playing at any position. Ideally, it should be of this form: language + libraries/APIs/etc. I don't mind writing a GUI program though, if it turns out to be more convenient. 

But any suggestion is appreciated!


----------



## shuxuef (Apr 3, 2010)

richardpl said:
			
		

> Have you tried smplayer? You could create similar fancy application like amarok (which is using gstreamer/libxine) just with using mplayer.



Not before you tell me. Thanks for that! But smplayer is like xmms--- it doesn't give the user any information regarding current track information (title/author, etc). Plus, the track switching is a bit brutal, it's like restarting mplayer in order to switch the track. A simple shell script would be able to do that.  



			
				richardpl said:
			
		

> And BTW you are asking it in wrong forum.



If that's the case, I am really sorry.


----------



## psycho (Apr 3, 2010)

&quot said:
			
		

> I think I am just interested in picking up some programming language that is ideal for this particular purpose, writing a text-based CD player


there is a nice port (by killasmurf86) : multimedia/playd


----------



## richardpl (Apr 4, 2010)

shuxuef said:
			
		

> Not before you tell me. Thanks for that! But smplayer is like xmms--- it doesn't give the user any information regarding current track information (title/author, etc). Plus, the track switching is a bit brutal, it's like restarting mplayer in order to switch the track. A simple shell script would be able to do that.



WTF are you talking about? There is no single program on Earth which can display current track information (title/author) from bare audio cd.

mplayer supports slave mode, I dont know how smplayer really works but in slave mode mplayer is not restarted.

(ncurses+)cdparanoia is all what you need, you could even add such support to cmus.


----------



## shuxuef (Apr 4, 2010)

richardpl said:
			
		

> WTF are you talking about? There is no single program on Earth which can display current track information (title/author) from bare audio cd.


Exactly when did I say that? Using CDDB or the like is perfectly allowed!



			
				richardpl said:
			
		

> mplayer supports slave mode, I dont know how smplayer really works but in slave mode mplayer is not restarted.
> 
> (ncurses+)cdparanoia is all what you need, you could even add such support to cmus.



On the face of it, cdparanoia doesn't seem to be a good choice,  since it does not direct the data to sound card instantly(even with pipe); but the paranoia library might be useful. Thanks for the information!


----------



## shuxuef (Apr 4, 2010)

psycho said:
			
		

> there is a nice port (by killasmurf86) : multimedia/playd



That's nice!


----------



## richardpl (Apr 4, 2010)

Try cdio (from OpenBSD).


----------



## shuxuef (Apr 4, 2010)

richardpl said:
			
		

> Try cdio (from OpenBSD).



How? I don't have OpenBSD.


----------



## richardpl (Apr 4, 2010)

Read the source.


----------



## shuxuef (Apr 4, 2010)

richardpl said:
			
		

> Read the source.



Cdio is an enhanced version of cdcontrol. In the source, they use a library called sndio.h, which exculsively belongs to OpenBSD. I suppose if I want to modify the cdcontrol on FreeBSD, I should learn how to control the sound system on it. Looks like a quick way to find it out is still to read the source code of cdda2wav.


----------

