OpenShot Library | OpenShotAudio  0.2.2
juce::WavAudioFormat Class Reference

Reads and Writes WAV format audio files. More...

#include <juce_WavAudioFormat.h>

+ Inheritance diagram for juce::WavAudioFormat:

Public Member Functions

 WavAudioFormat ()
 Creates a format object.
 
 ~WavAudioFormat () override
 Destructor.
 
Array< int > getPossibleSampleRates () override
 Returns a set of sample rates that the format can read and write.
 
Array< int > getPossibleBitDepths () override
 Returns a set of bit depths that the format can read and write.
 
bool canDoStereo () override
 Returns true if the format can do 2-channel audio.
 
bool canDoMono () override
 Returns true if the format can do 1-channel audio.
 
bool isChannelLayoutSupported (const AudioChannelSet &channelSet) override
 Returns true if the channel layout is supported by this format.
 
AudioFormatReadercreateReaderFor (InputStream *sourceStream, bool deleteStreamIfOpeningFails) override
 Tries to create an object that can read from a stream containing audio data in this format. More...
 
MemoryMappedAudioFormatReadercreateMemoryMappedReader (const File &) override
 Attempts to create a MemoryMappedAudioFormatReader, if possible for this format. More...
 
MemoryMappedAudioFormatReadercreateMemoryMappedReader (FileInputStream *) override
 
AudioFormatWritercreateWriterFor (OutputStream *streamToWriteTo, double sampleRateToUse, unsigned int numberOfChannels, int bitsPerSample, const StringPairArray &metadataValues, int qualityOptionIndex) override
 Tries to create an object that can write to a stream with this audio format. More...
 
AudioFormatWritercreateWriterFor (OutputStream *streamToWriteTo, double sampleRateToUse, const AudioChannelSet &channelLayout, int bitsPerSample, const StringPairArray &metadataValues, int qualityOptionIndex) override
 Tries to create an object that can write to a stream with this audio format. More...
 
bool replaceMetadataInFile (const File &wavFile, const StringPairArray &newMetadata)
 Utility function to replace the metadata in a wav file with a new set of values. More...
 
virtual AudioFormatWritercreateWriterFor (OutputStream *streamToWriteTo, double sampleRateToUse, unsigned int numberOfChannels, int bitsPerSample, const StringPairArray &metadataValues, int qualityOptionIndex)=0
 Tries to create an object that can write to a stream with this audio format. More...
 
virtual AudioFormatWritercreateWriterFor (OutputStream *streamToWriteTo, double sampleRateToUse, const AudioChannelSet &channelLayout, int bitsPerSample, const StringPairArray &metadataValues, int qualityOptionIndex)
 Tries to create an object that can write to a stream with this audio format. More...
 
- Public Member Functions inherited from juce::AudioFormat
virtual ~AudioFormat ()
 Destructor.
 
const StringgetFormatName () const
 Returns the name of this format. More...
 
virtual StringArray getFileExtensions () const
 Returns all the file extensions that might apply to a file of this format. More...
 
virtual bool canHandleFile (const File &fileToTest)
 Returns true if this the given file can be read by this format. More...
 
virtual bool isCompressed ()
 Returns true if the format uses compressed data.
 
virtual StringArray getQualityOptions ()
 Returns a list of different qualities that can be used when writing. More...
 

Static Public Member Functions

static StringPairArray createBWAVMetadata (const String &description, const String &originator, const String &originatorRef, Time dateAndTime, int64 timeReferenceSamples, const String &codingHistory)
 Utility function to fill out the appropriate metadata for a BWAV file. More...
 

Static Public Attributes

static const char *const bwavDescription = "bwav description"
 Metadata property name used in BWAV chunks.
 
static const char *const bwavOriginator = "bwav originator"
 Metadata property name used in BWAV chunks.
 
static const char *const bwavOriginatorRef = "bwav originator ref"
 Metadata property name used in BWAV chunks.
 
static const char *const bwavOriginationDate = "bwav origination date"
 Metadata property name used in BWAV chunks. More...
 
static const char *const bwavOriginationTime = "bwav origination time"
 Metadata property name used in BWAV chunks. More...
 
static const char *const bwavCodingHistory = "bwav coding history"
 Metadata property name used in BWAV chunks.
 
static const char *const bwavTimeReference = "bwav time reference"
 Metadata property name used in BWAV chunks. More...
 
static const char *const acidOneShot = "acid one shot"
 Metadata property name used in acid chunks.
 
static const char *const acidRootSet = "acid root set"
 Metadata property name used in acid chunks.
 
static const char *const acidStretch = "acid stretch"
 Metadata property name used in acid chunks.
 
static const char *const acidDiskBased = "acid disk based"
 Metadata property name used in acid chunks.
 
static const char *const acidizerFlag = "acidizer flag"
 Metadata property name used in acid chunks.
 
static const char *const acidRootNote = "acid root note"
 Metadata property name used in acid chunks.
 
static const char *const acidBeats = "acid beats"
 Metadata property name used in acid chunks.
 
static const char *const acidDenominator = "acid denominator"
 Metadata property name used in acid chunks.
 
static const char *const acidNumerator = "acid numerator"
 Metadata property name used in acid chunks.
 
static const char *const acidTempo = "acid tempo"
 Metadata property name used in acid chunks.
 
static const char *const riffInfoArchivalLocation = "IARL"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoArtist = "IART"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoBaseURL = "IBSU"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoCinematographer = "ICNM"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoComment = "CMNT"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoComment2 = "ICMT"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoComments = "COMM"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoCommissioned = "ICMS"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoCopyright = "ICOP"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoCostumeDesigner = "ICDS"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoCountry = "ICNT"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoCropped = "ICRP"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoDateCreated = "ICRD"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoDateTimeOriginal = "IDIT"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoDefaultAudioStream = "ICAS"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoDimension = "IDIM"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoDirectory = "DIRC"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoDistributedBy = "IDST"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoDotsPerInch = "IDPI"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoEditedBy = "IEDT"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoEighthLanguage = "IAS8"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoEncodedBy = "CODE"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoEndTimecode = "TCDO"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoEngineer = "IENG"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoFifthLanguage = "IAS5"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoFirstLanguage = "IAS1"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoFourthLanguage = "IAS4"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoGenre = "GENR"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoKeywords = "IKEY"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoLanguage = "LANG"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoLength = "TLEN"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoLightness = "ILGT"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoLocation = "LOCA"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoLogoIconURL = "ILIU"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoLogoURL = "ILGU"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoMedium = "IMED"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoMoreInfoBannerImage = "IMBI"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoMoreInfoBannerURL = "IMBU"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoMoreInfoText = "IMIT"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoMoreInfoURL = "IMIU"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoMusicBy = "IMUS"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoNinthLanguage = "IAS9"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoNumberOfParts = "PRT2"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoOrganisation = "TORG"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoPart = "PRT1"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoProducedBy = "IPRO"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoProductName = "IPRD"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoProductionDesigner = "IPDS"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoProductionStudio = "ISDT"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoRate = "RATE"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoRated = "AGES"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoRating = "IRTD"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoRippedBy = "IRIP"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoSecondaryGenre = "ISGN"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoSecondLanguage = "IAS2"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoSeventhLanguage = "IAS7"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoSharpness = "ISHP"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoSixthLanguage = "IAS6"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoSoftware = "ISFT"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoSoundSchemeTitle = "DISP"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoSource = "ISRC"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoSourceFrom = "ISRF"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoStarring_ISTR = "ISTR"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoStarring_STAR = "STAR"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoStartTimecode = "TCOD"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoStatistics = "STAT"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoSubject = "ISBJ"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoTapeName = "TAPE"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoTechnician = "ITCH"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoThirdLanguage = "IAS3"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoTimeCode = "ISMP"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoTitle = "INAM"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoTrackNo = "IPRT"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoTrackNumber = "TRCK"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoURL = "TURL"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoVegasVersionMajor = "VMAJ"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoVegasVersionMinor = "VMIN"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoVersion = "TVER"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoWatermarkURL = "IWMU"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoWrittenBy = "IWRI"
 Metadata property name used in INFO chunks.
 
static const char *const riffInfoYear = "YEAR"
 Metadata property name used in INFO chunks.
 
static const char *const ISRC = "ISRC"
 Metadata property name used when reading an ISRC code from an AXML chunk.
 
static const char *const tracktionLoopInfo = "tracktion loop info"
 Metadata property name used when reading a WAV file with a Tracktion chunk.
 

Additional Inherited Members

- Protected Member Functions inherited from juce::AudioFormat
 AudioFormat (String formatName, StringArray fileExtensions)
 Creates an AudioFormat object. More...
 
 AudioFormat (StringRef formatName, StringRef fileExtensions)
 Creates an AudioFormat object. More...
 

Detailed Description

Reads and Writes WAV format audio files.

See also
AudioFormat

Definition at line 42 of file juce_WavAudioFormat.h.

Member Function Documentation

◆ createBWAVMetadata()

StringPairArray juce::WavAudioFormat::createBWAVMetadata ( const String description,
const String originator,
const String originatorRef,
Time  dateAndTime,
int64  timeReferenceSamples,
const String codingHistory 
)
static

Utility function to fill out the appropriate metadata for a BWAV file.

This just makes it easier than using the property names directly, and it fills out the time and date in the right format.

Definition at line 41 of file juce_WavAudioFormat.cpp.

References bwavCodingHistory, bwavDescription, bwavOriginationDate, bwavOriginationTime, bwavOriginator, bwavOriginatorRef, bwavTimeReference, juce::Time::formatted(), and juce::StringPairArray::set().

◆ createReaderFor()

AudioFormatReader * juce::WavAudioFormat::createReaderFor ( InputStream sourceStream,
bool  deleteStreamIfOpeningFails 
)
overridevirtual

Tries to create an object that can read from a stream containing audio data in this format.

The reader object that is returned can be used to read from the stream, and should then be deleted by the caller.

Parameters
sourceStreamthe stream to read from - the AudioFormatReader object that is returned will delete this stream when it no longer needs it.
deleteStreamIfOpeningFailsif no reader can be created, this determines whether this method should delete the stream object that was passed-in. (If a valid reader is returned, it will always be in charge of deleting the stream, so this parameter is ignored)
See also
AudioFormatReader

Implements juce::AudioFormat.

Definition at line 1683 of file juce_WavAudioFormat.cpp.

References juce::OggVorbisAudioFormat::createReaderFor(), and juce::AudioFormatReader::input.

Referenced by replaceMetadataInFile().

◆ createMemoryMappedReader()

MemoryMappedAudioFormatReader * juce::WavAudioFormat::createMemoryMappedReader ( const File file)
overridevirtual

Attempts to create a MemoryMappedAudioFormatReader, if possible for this format.

If the format does not support this, the method will return nullptr;

Reimplemented from juce::AudioFormat.

Definition at line 1704 of file juce_WavAudioFormat.cpp.

References juce::File::createInputStream().

◆ createWriterFor() [1/4]

AudioFormatWriter * juce::WavAudioFormat::createWriterFor ( OutputStream streamToWriteTo,
double  sampleRateToUse,
unsigned int  numberOfChannels,
int  bitsPerSample,
const StringPairArray metadataValues,
int  qualityOptionIndex 
)
overridevirtual

Tries to create an object that can write to a stream with this audio format.

The writer object that is returned can be used to write to the stream, and should then be deleted by the caller.

If the stream can't be created for some reason (e.g. the parameters passed in here aren't suitable), this will return nullptr.

Parameters
streamToWriteTothe stream that the data will go to - this will be deleted by the AudioFormatWriter object when it's no longer needed. If no AudioFormatWriter can be created by this method, the stream will NOT be deleted, so that the caller can re-use it to try to open a different format, etc
sampleRateToUsethe sample rate for the file, which must be one of the ones returned by getPossibleSampleRates()
numberOfChannelsthe number of channels
bitsPerSamplethe bits per sample to use - this must be one of the values returned by getPossibleBitDepths()
metadataValuesa set of metadata values that the writer should try to write to the stream. Exactly what these are depends on the format, and the subclass doesn't actually have to do anything with them if it doesn't want to. Have a look at the specific format implementation classes to see possible values that can be used
qualityOptionIndexthe index of one of compression qualities returned by the getQualityOptions() method. If there aren't any quality options for this format, just pass 0 in this parameter, as it'll be ignored
See also
AudioFormatWriter

Implements juce::AudioFormat.

Definition at line 1722 of file juce_WavAudioFormat.cpp.

References createWriterFor().

◆ createWriterFor() [2/4]

AudioFormatWriter * juce::WavAudioFormat::createWriterFor ( OutputStream streamToWriteTo,
double  sampleRateToUse,
const AudioChannelSet channelLayout,
int  bitsPerSample,
const StringPairArray metadataValues,
int  qualityOptionIndex 
)
overridevirtual

Tries to create an object that can write to a stream with this audio format.

The writer object that is returned can be used to write to the stream, and should then be deleted by the caller.

If the stream can't be created for some reason (e.g. the parameters passed in here aren't suitable), this will return nullptr.

Parameters
streamToWriteTothe stream that the data will go to - this will be deleted by the AudioFormatWriter object when it's no longer needed. If no AudioFormatWriter can be created by this method, the stream will NOT be deleted, so that the caller can re-use it to try to open a different format, etc
sampleRateToUsethe sample rate for the file, which must be one of the ones returned by getPossibleSampleRates()
channelLayoutthe channel layout for the file. Use isChannelLayoutSupported to check if the writer supports this layout.
bitsPerSamplethe bits per sample to use - this must be one of the values returned by getPossibleBitDepths()
metadataValuesa set of metadata values that the writer should try to write to the stream. Exactly what these are depends on the format, and the subclass doesn't actually have to do anything with them if it doesn't want to. Have a look at the specific format implementation classes to see possible values that can be used
qualityOptionIndexthe index of one of compression qualities returned by the getQualityOptions() method. If there aren't any quality options for this format, just pass 0 in this parameter, as it'll be ignored
See also
AudioFormatWriter

Reimplemented from juce::AudioFormat.

Definition at line 1730 of file juce_WavAudioFormat.cpp.

References getPossibleBitDepths(), and isChannelLayoutSupported().

◆ replaceMetadataInFile()

bool juce::WavAudioFormat::replaceMetadataInFile ( const File wavFile,
const StringPairArray newMetadata 
)

Utility function to replace the metadata in a wav file with a new set of values.

If possible, this cheats by overwriting just the metadata region of the file, rather than by copying the whole file again.

Definition at line 1780 of file juce_WavAudioFormat.cpp.

References juce::File::createInputStream(), createReaderFor(), juce::File::getSize(), juce::FileOutputStream::openedOk(), and juce::FileOutputStream::setPosition().

◆ createWriterFor() [3/4]

virtual AudioFormatWriter* juce::AudioFormat::createWriterFor

Tries to create an object that can write to a stream with this audio format.

The writer object that is returned can be used to write to the stream, and should then be deleted by the caller.

If the stream can't be created for some reason (e.g. the parameters passed in here aren't suitable), this will return nullptr.

Parameters
streamToWriteTothe stream that the data will go to - this will be deleted by the AudioFormatWriter object when it's no longer needed. If no AudioFormatWriter can be created by this method, the stream will NOT be deleted, so that the caller can re-use it to try to open a different format, etc
sampleRateToUsethe sample rate for the file, which must be one of the ones returned by getPossibleSampleRates()
numberOfChannelsthe number of channels
bitsPerSamplethe bits per sample to use - this must be one of the values returned by getPossibleBitDepths()
metadataValuesa set of metadata values that the writer should try to write to the stream. Exactly what these are depends on the format, and the subclass doesn't actually have to do anything with them if it doesn't want to. Have a look at the specific format implementation classes to see possible values that can be used
qualityOptionIndexthe index of one of compression qualities returned by the getQualityOptions() method. If there aren't any quality options for this format, just pass 0 in this parameter, as it'll be ignored
See also
AudioFormatWriter

Referenced by createWriterFor().

◆ createWriterFor() [4/4]

AudioFormatWriter * juce::AudioFormat::createWriterFor

Tries to create an object that can write to a stream with this audio format.

The writer object that is returned can be used to write to the stream, and should then be deleted by the caller.

If the stream can't be created for some reason (e.g. the parameters passed in here aren't suitable), this will return nullptr.

Parameters
streamToWriteTothe stream that the data will go to - this will be deleted by the AudioFormatWriter object when it's no longer needed. If no AudioFormatWriter can be created by this method, the stream will NOT be deleted, so that the caller can re-use it to try to open a different format, etc
sampleRateToUsethe sample rate for the file, which must be one of the ones returned by getPossibleSampleRates()
channelLayoutthe channel layout for the file. Use isChannelLayoutSupported to check if the writer supports this layout.
bitsPerSamplethe bits per sample to use - this must be one of the values returned by getPossibleBitDepths()
metadataValuesa set of metadata values that the writer should try to write to the stream. Exactly what these are depends on the format, and the subclass doesn't actually have to do anything with them if it doesn't want to. Have a look at the specific format implementation classes to see possible values that can be used
qualityOptionIndexthe index of one of compression qualities returned by the getQualityOptions() method. If there aren't any quality options for this format, just pass 0 in this parameter, as it'll be ignored
See also
AudioFormatWriter

Definition at line 192 of file juce_AudioFormat.cpp.

Member Data Documentation

◆ bwavOriginationDate

const char *const juce::WavAudioFormat::bwavOriginationDate = "bwav origination date"
static

Metadata property name used in BWAV chunks.

The format should be: yyyy-mm-dd

Definition at line 58 of file juce_WavAudioFormat.h.

Referenced by createBWAVMetadata().

◆ bwavOriginationTime

const char *const juce::WavAudioFormat::bwavOriginationTime = "bwav origination time"
static

Metadata property name used in BWAV chunks.

The format should be: format is: hh-mm-ss

Definition at line 59 of file juce_WavAudioFormat.h.

Referenced by createBWAVMetadata().

◆ bwavTimeReference

const char *const juce::WavAudioFormat::bwavTimeReference = "bwav time reference"
static

Metadata property name used in BWAV chunks.

This is the number of samples from the start of an edit that the file is supposed to begin at. Seems like an obvious mistake to only allow a file to occur in an edit once, but that's the way it is..

See also
AudioFormatReader::metadataValues, createWriterFor

Definition at line 70 of file juce_WavAudioFormat.h.

Referenced by createBWAVMetadata().


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