aus.audiofile

class AudioFile
__init__(self, **kwargs)

Initializes an AudioFile object. You can pass the following keyword parameters to this method (from https://ccrma.stanford.edu/courses/422-winter-2014/projects/WaveFormat/):

audio_format: The audio format (should generally be 1) bits_per_sample: The number of bits per sample (often 8, 16, 24, or 32) block_align: The block align setting (size in bytes of one frame of audio, including all channels) byte_rate: Number of bytes per second bytes_per_sample: The number of bytes per sample (corresponding to bits_per_sample) duration: The duration in seconds file_name: The full path of the file_name num_channels: The number of channels frames: The number of frames sample_rate: The sample byte_rate

copy_header(other)

Copies the header of another AudioFile object and returns a new AudioFile object with the header copied. Does not copy the audio samples.

Parameters:

other – The AudioFile to copy the header from

Returns:

A new AudioFile object

Return type:

AudioFile

convert(file: AudioFile, format: str)

Converts an AudioFile from one sample format to another. Use this to change between int and float format, or to change bit depth (e.g. 16 to 24 bit). Supported conversion types: 'int16', 'int24', 'int32', 'float32', 'float64'

Parameters:
  • file (AudioFile) – An AudioFile

  • format (str) – The destination format

find_files(directory_name: str)

Finds all WAV and AIFF files within a directory and its subdirectories

Parameters:

directory_name (str) – The directory name

Returns:

A list of file names

Return type:

list

read(file_name: str, target_sample_rate: int)

Reads an audio file (AIFF or WAV) and returns an AudioFile object containing the contents of the file. It uses the pedalboard library for speed.

Parameters:
  • file_name (str) – The name of the file

  • target_sample_rate – The target sample rate of the audio

Returns:

An AudioFile

Return type:

AudioFile

write_with_pedalboard(audio: AudioFile, file_name: str)

Writes an audio file using the pedalboard library

Parameters:
  • audio (AudioFile) – The AudioFile object

  • file_name (str) – The file name to use