As far as I know, audio tracks are .WAV files, so you can read them the same way you read normal files from a CD.
eg
public static void main(String[] args) {
File dir = new File("D:\\"); //on linux I think you must mount the CD first
String[] tracks = dir.list();
for(String i : tracks) {
System.out.println(i);
}
}
> As far as I know, audio tracks are .WAV files, so you
> can read them the same way you read normal files from
> a CD.
Then you dont know! just kidding ; )
CD Audio is actually in the Red Book Audio Standard
http://en.wikipedia.org/wiki/Red_Book_(audio_CD_standard)
It is essentially a WAV format in 16 44100.
However reading it from the CD is in NO WAY equivalent to
reading a file from the harddrive.
It requires OS dependent native code.
You need to google how to open .cda (cdda) files.
There are libraries out there for this that utilize JNI but they are
wholly platform dependent.
> ...
> Then you dont know! just kidding ; )
>
> CD Audio is actually in the Red Book Audio Standard
> http://en.wikipedia.org/wiki/Red_Book_(audio_CD_standard)
>
> It is essentially a WAV format in 16 44100.
> However reading it from the CD is in NO WAY
> equivalent to reading a file from the harddrive.
> It requires OS dependent native code.
>
> You need to google how to open .cda (cdda) files.
> There are libraries out there for this that utilize
> JNI but they are
> wholly platform dependent.
@OP: so the answer to your question is: no.
; )
If you look at the javax.sound.sampled package you'll find for example this class http://java.sun.com/javase/6/docs/api/javax/sound/sampled/Port.Info.html
which does suggest that you can use the sound API to access the tracks on a cd (there's a static field named COMPACT_DISC).
So I would say that the answer is in fact yes, you can create a stream to read the bytes off a cd, but I can't say for sure, since I haven't used the API myself.
You would probably have more luck at the sound forum.
#
> If you look at the javax.sound.sampled package you'll
> find for example this class
> http://java.sun.com/javase/6/docs/api/javax/sound/samp
> led/Port.Info.html
> which does suggest that you can use the sound API to
> access the tracks on a cd (there's a static field
> named COMPACT_DISC).
>
> So I would say that the answer is in fact yes,
> you can create a stream to read the bytes off a cd,
> but I can't say for sure, since I haven't used the
> API myself.
>
> You would probably have more luck at the sound
> forum.
>
> #
The java media classes use native code (just like all i/o operations). So the answer to the OP question if s/he can read the bytes from an audio cd with pure Java code, is no.
> So I would say that the answer is in fact yes,
> you can create a stream to read the bytes off a cd,
> but I can't say for sure, since I haven't used the
> API myself.
using a PORT would require grabbing the bytes in real time as
it was playing. i dont believe there is random access or control
either.
using a library to read cdda "files" (theyre actually 32bit? system
shortcuts) you could do random access and much faster bulk reads
from the cd (for encoding and such).
if you read the tritonus and cdparanoia (linux only i believe) pages
youll see that cdda reading is a bit involved.
http://tritonus.org/plugins.html
ps - the point being, there are MANY opens source windows command line cd extractors / accessors. you could easily call them with Runtime or port with them with JNI.
> The java media classes use native code (just like all
> i/o operations). So the answer to the OP question if
> s/he can read the bytes from an audio cd with pure
> Java code, is no.
True but the OP need not write any JNI code himself. So in that sense he can accomplish his task in "pure java". =)
#
> > The java media classes use native code (just like
> all
> > i/o operations). So the answer to the OP question
> if
> > s/he can read the bytes from an audio cd with pure
> > Java code, is no.
>
> True but the OP need not write any JNI code himself.
> So in that sense he can accomplish his task in
> "pure java". =)
>
> #
Wrong. The OP said " Not playing them, just getting the bytes".
You CAN NOT do that with PORT.
The OP WILL need a platform dependent natively written program.
Sure he can invoke it with Runtime but he would most likely have to
extract the entire track to a wav file and then read from the wav file.
> The java media classes use native code (just like all
> i/o operations). So the answer to the OP question if
> s/he can read the bytes from an audio cd with pure
> Java code, is no.
With this argumentation you could say that no files can be read from a CD (or a hard disk for that matter) in pure java because of the native code involved with I/O, moreover there can be no pure java code at all, given the fact we need a JVM.
> ...
> With this argumentation you could say that no files
> can be read from a CD (or a hard disk for that
> matter) in pure java because of the native code
> involved with I/O, moreover there can be no pure java
> code at all, given the fact we need a JVM.
You could say that, yes. One could also say that everything that only exists in the JVM is pure Java code (I know: vague terminology, hope you get my point).
Note that I said this to make it clear to the OP that a lot of core classes in the JDK make use of native code.