WAVData

Author:
Armin Trattnig
Version:
1.0
Includes:
<stdio.h>
<stdlib.h>
<wavIO.h>
"DRCAtoms.h"

Introduction

Use the links in the table of contents to the left to access the documentation.

Updated:
Wednesday, September 10, 2014


Functions

closeWAVDataFile
initWAVDataForReading
initWAVDataForWriting
readFrame
writeFrame

closeWAVDataFile


MP4Err closeWAVDataFile (
    WAVData *wavData);  
Parameters
wavData

Pointer to an initialized WAVData structure

Return Value

An MP4Err, which is defined libisomediafile.a; MP4NoErr if nothing fails

Discussion

Updates the size fields in the wav header and closes the wav file


initWAVDataForReading


MP4Err initWAVDataForReading (
    WAVData *wavData,
    char *inputFileStr);  
Parameters
wavData

Pointer to a allocated WAVData structure

inputFileStr

Path to a wav file

Return Value

An MP4Err, which is defined libisomediafile.a; MP4NoErr if nothing fails

Discussion

Initializes WAV data from a file for reading


initWAVDataForWriting


MP4Err initWAVDataForWriting (
    WAVData *wavData,
    char *outputFileStr,
    int channelCount,
    int sampleRate,
    int bytesPerSample);  
Parameters
wavData

Pointer to a allocated WAVData structure

outputFileStr

File, to which the audio data will be written

channelCount

The amount of channels in the audio data

sampleRate

The samplerate of the audio data

bytesPerSample

Byte depth of an audio sample

Return Value

An MP4Err, which is defined libisomediafile.a; MP4NoErr if nothing fails

Discussion

Initializes WAV data from a file for writing


readFrame


MP4Err readFrame (
    WAVData *wavData,
    MP4Handle sampleH,
    u32 *duration);  
Parameters
wavData

Pointer to an initialized WAVData structure

sampleH

MP4 handle, which will contain the audio frame

duration

The number of samples contained in the audio frame, which is equal to the duration

Return Value

An MP4Err, which is defined libisomediafile.a; MP4NoErr if nothing fails

Discussion

Reads an audio frame form the wav input file


writeFrame


MP4Err writeFrame (
    WAVData *wavData,
    MP4Handle sampleH,
    u32 size);  
Parameters
wavData

Pointer to a for writing initialized WAVData structure

sampleH

MP4 handle, which contains the audio frame

size

Size in bytes of the input mp4handle

Return Value

An MP4Err, which is defined libisomediafile.a; MP4NoErr if nothing fails

Discussion

Writes an audio frame to the wav output file


Typedefs

WAVData

Contains the information about a wav audio file and the handles to read the wav audio file. *


WAVData


Contains the information about a wav audio file and the handles to read the wav audio file. *

typedef struct WAVData { 
    WAVIO_HANDLE wavIOHandle; 
    FILE *file; 
    unsigned int channels; 
    unsigned int sampleRate; 
    unsigned int byteDepth; 
    unsigned long totalSamplesPerChannel; 
    int samplesPerChannelFilled; 
    u32 totalBytesWritten; 
} WAVData;  
Fields
wavIOHandle

Handle for wavIO library *

inputFile

The wav input file *

channels

The number of audio channels in the wav audio file *

sampleRate

The samplerate of the audio *

byteDepth

The bytes per sample (wavIO converts 16 bit PCM to 32 bit float PCM!) *

totalSamplesPerChannel

Number of samples per channel in total *

samplesPerChannelFilled

Number of samples per channels filled


Enumerated Types

DRC

Extends the list of atom types from MP4Atoms.h with atoms used with drc data


DRC


Extends the list of atom types from MP4Atoms.h with atoms used with drc data

enum { 
    AudioUnsigned16BitLittleEndianSampleEntryType = MP4_FOUR_CHAR_CODE(
        'r',
        'a',
        'w',
        ' ' ), 
    AudioSigned16BitBigEndianSampleEntryType = MP4_FOUR_CHAR_CODE(
        't',
        'w',
        'o',
        's' ), 
    AudioSigned16BitLittleEndianSampleEntryType = MP4_FOUR_CHAR_CODE(
        's',
        'o',
        'w',
        't' ) 
};  
Constants
DRCUniDrcSampleEntryAtomType

Type for DRCUniDrcSampleEntry. "unid"

DRCCoefficientBasicAtomType

Type for DRCCoefficientBasic. "udc1"

DRCInstructionsBasicAtomType

Type for DRCInstructionsBasic. "udi1"

DRCCoefficientUniDRCAtomType

Type for DRCCoefficientUniDRC. "udc2"

DRCInstructionsUniDRCAtomType

Type for DRCInstructionsUniDRC. "udi2"

Discussion

Atoms


Macro Definitions

BLOCKLENGTH

BLOCKLENGTH


#define BLOCKLENGTH 1024 
Included Defines
BLOCKLENGTH

The number of samples contained in one audio frame