AudioCDReader Class Reference
juce_audio_utils » audio_cd

A type of AudioFormatReader that reads from an audio CD. More...

Inheritance diagram for AudioCDReader:

## Public Types

enum | { framesPerSecond = 75, samplesPerFrame = 44100 / framesPerSecond }

## Public Member Functions

| ~AudioCDReader ()
| Destructor. More...
bool | readSamples (int **destSamples, int numDestChannels, int startOffsetInDestBuffer, int64 startSampleInFile, int numSamples) override
| Implementation of the AudioFormatReader method. More...
bool | isCDStillPresent () const
| Checks whether the CD has been removed from the drive. More...
int | getNumTracks () const
| Returns the total number of tracks (audio + data). More...
int | getPositionOfTrackStart (int trackNum) const
| Finds the sample offset of the start of a track. More...
bool | isTrackAudio (int trackNum) const
| Returns true if a given track is an audio track. More...
const Array< int > & | getTrackOffsets () const
| Returns an array of sample offsets for the start of each track, followed by the sample position of the end of the CD. More...
void | refreshTrackLengths ()
| Refreshes the object's table of contents. More...
void | enableIndexScanning (bool enabled)
| Enables scanning for indexes within tracks. More...
int | getLastIndex () const
| Returns the index number found during the last read() call. More...
Array< int > | findIndexesInTrack (const int trackNumber)
| Scans a track to find the position of any indexes within it. More...
int | getCDDBId ()
| Returns the CDDB id number for the CD. More...
void | ejectDisk ()
| Tries to eject the disk. More...
Public Member Functions inherited from AudioFormatReader
virtual | ~AudioFormatReader ()
| Destructor. More...
const String & | getFormatName () const noexcept
| Returns a description of what type of format this is. More...
bool | read (float *const *destChannels, int numDestChannels, int64 startSampleInSource, int numSamplesToRead)
| Reads samples from the stream. More...
bool | read (int *const *destChannels, int numDestChannels, int64 startSampleInSource, int numSamplesToRead, bool fillLeftoverChannelsWithCopies)
| Reads samples from the stream. More...
void | read (AudioBuffer< float > *buffer, int startSampleInDestBuffer, int numSamples, int64 readerStartSample, bool useReaderLeftChan, bool useReaderRightChan)
| Fills a section of an AudioBuffer from this reader. More...
virtual void | readMaxLevels (int64 startSample, int64 numSamples, Range< float > *results, int numChannelsToRead)
| Finds the highest and lowest sample levels from a section of the audio stream. More...
virtual void | readMaxLevels (int64 startSample, int64 numSamples, float &lowestLeft, float &highestLeft, float &lowestRight, float &highestRight)
| Finds the highest and lowest sample levels from a section of the audio stream. More...
int64 | searchForLevel (int64 startSample, int64 numSamplesToSearch, double magnitudeRangeMinimum, double magnitudeRangeMaximum, int minimumConsecutiveSamples)
| Scans the source looking for a sample whose magnitude is in a specified range. More...
virtual AudioChannelSet | getChannelLayout ()
| Get the channel layout of the audio stream. More...

## Static Public Member Functions

static StringArray | getAvailableCDNames ()
| Returns a list of names of Audio CDs currently available for reading. More...
static AudioCDReader * | createReaderForCD (const int index)
| Tries to create an AudioFormatReader that can read from an Audio CD. More...

## Additional Inherited Members

Public Attributes inherited from AudioFormatReader
double | sampleRate = 0
| The sample-rate of the stream. More...
unsigned int | bitsPerSample = 0
| The number of bits per sample, e.g. More...
int64 | lengthInSamples = 0
| The total number of samples in the audio stream. More...
unsigned int | numChannels = 0
| The total number of channels in the audio stream. More...
bool | usesFloatingPointData = false
| Indicates whether the data is floating-point or fixed. More...
StringPairArray | metadataValues
| A set of metadata values that the reader has pulled out of the stream. More...
InputStream * | input
| The input stream, for use by subclasses. More...
Protected Member Functions inherited from AudioFormatReader
| AudioFormatReader (InputStream *sourceStream, const String &formatName)
| Creates an AudioFormatReader object. More...
Static Protected Member Functions inherited from AudioFormatReader
static void | clearSamplesBeyondAvailableLength (int **destChannels, int numDestChannels, int startOffsetInDestBuffer, int64 startSampleInFile, int &numSamples, int64 fileLengthInSamples)
| Used by AudioFormatReader subclasses to clear any parts of the data blocks that lie beyond the end of their available length. More...

## Detailed Description

A type of AudioFormatReader that reads from an audio CD.

One of these can be used to read a CD as if it's one big audio stream. Use the getPositionOfTrackStart() method to find where the individual tracks are within the stream.

See also
  AudioFormatReader

## Member Enumeration Documentation

## anonymous enum

anonymous enum

Enumerator
framesPerSecond |
samplesPerFrame |

## Constructor & Destructor Documentation

## ~AudioCDReader()

AudioCDReader::~AudioCDReader | ( |  | ) |

Destructor.

## Member Function Documentation

## getAvailableCDNames()

static StringArray AudioCDReader::getAvailableCDNames | ( |  | ) |

static

Returns a list of names of Audio CDs currently available for reading.

If there's a CD drive but no CD in it, this might return an empty list, or possibly a device that can be opened but which has no tracks, depending on the platform.

See also
  createReaderForCD

## createReaderForCD()

static AudioCDReader* AudioCDReader::createReaderForCD | ( | const int | index | ) |

static

Tries to create an AudioFormatReader that can read from an Audio CD.

Parameters

  index | the index of one of the available CDs - use getAvailableCDNames() to find out how many there are.

Returns
  a new AudioCDReader object, or nullptr if it couldn't be created. The caller will be responsible for deleting the object returned.

## readSamples()

bool AudioCDReader::readSamples | ( | int ** | destSamples,
|  | int | numDestChannels,
|  | int | startOffsetInDestBuffer,
|  | int64 | startSampleInFile,
|  | int | numSamples
| ) |  |

override virtual

Implementation of the AudioFormatReader method.

Implements AudioFormatReader.

## isCDStillPresent()

bool AudioCDReader::isCDStillPresent | ( |  | ) | const

Checks whether the CD has been removed from the drive.

## getNumTracks()

int AudioCDReader::getNumTracks | ( |  | ) | const

Returns the total number of tracks (audio + data).

## getPositionOfTrackStart()

int AudioCDReader::getPositionOfTrackStart | ( | int | trackNum | ) | const

Finds the sample offset of the start of a track.

Parameters

  trackNum | the track number, where trackNum = 0 is the first track and trackNum = getNumTracks() means the end of the CD.

## isTrackAudio()

bool AudioCDReader::isTrackAudio | ( | int | trackNum | ) | const

Returns true if a given track is an audio track.

Parameters

  trackNum | the track number, where 0 is the first track.

## getTrackOffsets()

const Array<int>& AudioCDReader::getTrackOffsets | ( |  | ) | const

Returns an array of sample offsets for the start of each track, followed by the sample position of the end of the CD.

## refreshTrackLengths()

void AudioCDReader::refreshTrackLengths | ( |  | ) |

Refreshes the object's table of contents.

If the disc has been ejected and a different one put in since this object was created, this will cause it to update its idea of how many tracks there are, etc.

## enableIndexScanning()

void AudioCDReader::enableIndexScanning | ( | bool | enabled | ) |

Enables scanning for indexes within tracks.

See also
  getLastIndex

## getLastIndex()

int AudioCDReader::getLastIndex | ( |  | ) | const

Returns the index number found during the last read() call.

Index scanning is turned off by default - turn it on with enableIndexScanning().

Then when the read() method is called, if it comes across an index within that block, the index number is stored and returned by this method.

Some devices might not support indexes, of course.

(If you don't know what CD indexes are, it's unlikely you'll ever need them).

See also
  enableIndexScanning

## findIndexesInTrack()

Array<int> AudioCDReader::findIndexesInTrack | ( | const int | trackNumber | ) |

Scans a track to find the position of any indexes within it.

Parameters

  trackNumber | the track to look in, where 0 is the first track on the disc

Returns
  an array of sample positions of any index points found (not including the index that marks the start of the track)

## getCDDBId()

int AudioCDReader::getCDDBId | ( |  | ) |

Returns the CDDB id number for the CD.

It's not a great way of identifying a disc, but it's traditional.

## ejectDisk()

void AudioCDReader::ejectDisk | ( |  | ) |

Tries to eject the disk.

Ejecting the disk might not actually be possible, e.g. if some other process is using it.

The documentation for this class was generated from the following file:

- juce_AudioCDReader.h