Still trying to get that CD to play

I’ve been playing around and trying to get a CD to play. I got everything I thought I needed happening, and I’d hit play and I’d hear the mechanics of the CD starting, but no sound. So I retrenched and tried to make the minimal possible alterations to the demo program in order to play a CD.

This is what I did:

  1. I altered the code in filenameComponentChanged, replacing
    [i]AudioFormatReader* reader = formatManager.createReaderFor /i;
    reader = AudioCDReader::createReaderForCD(0);

  2. Because I will later need the position of each track, I moved the declaration of reader to the private fields section, changing it to be:
    AudioCDReader* reader;

  3. I went into the buttonClicked() routine and changed it to:
    if (button == playButton)
    transportSource.setPosition (reader->getPositionOfTrackStart(1));

So now, of course I have to choose a file in order to get item 1 to execute, but that’s fine for testing.

Then I click play. the call to getPositionOfTrackStart returns 7344120, which seems like a reasonable number. But the CD doesn’t start playing, the Stop button is disabled, and the UI says “stopped”.

What am I missing here?

Thanks for any light you can shed.


what platform are you on? It’s worth stepping into the code to see how far it gets…

Well, at first I thought it might be problems because I’m developing in a virtual machine, using XP on the Mac. But it turns out that the problem was that I was seduced by the method names into believing that the getPositionOfTrackStart() method returned something that could be fed into the setPosition() method of the transportSource. whoops! divide by the sample rate and everything’s ok.

Now if this thing works under Vista, I will be one happy camper.