Gin
Loading...
Searching...
No Matches
AudioMetadata Class Reference

Extracts musical metadata from audio files. More...

#include <gin_audiometadata.h>

Public Member Functions

 AudioMetadata (const juce::File &f, juce::AudioFormatManager &mgr)
 Creates an AudioMetadata object by reading metadata from an audio file.

Public Attributes

std::optional< int > root
 The root note (MIDI note number 0-127).
std::optional< float > bpm
 The tempo in beats per minute.
std::optional< int > numerator
 Time signature numerator (beats per bar).
std::optional< int > denominator
 Time signature denominator (beat unit).
std::optional< int64_t > loopStart
 Loop start point in samples.
std::optional< int64_t > loopEnd
 Loop end point in samples (exclusive).

Detailed Description

Extracts musical metadata from audio files.

AudioMetadata reads loop, tempo, time signature, and root note information from WAV and AIFF files. It supports:

  • WAV files: ACID chunk (root note, BPM, time signature) and sampler chunk (loop points, root note via MidiUnityNote)
  • AIFF files: Apple Loops basc chunk (root note, BPM, time signature) and INST chunk loop points via cue markers

For files without embedded metadata, the class attempts to deduce:

  • Root note from the filename (e.g., "bass_C#.wav" -> C#)
  • BPM from the filename (e.g., "loop_120bpm.wav" -> 120) or cue labels

All metadata fields are optional and will only be set if the corresponding data is found in the file or can be deduced.

Usage:

juce::AudioFormatManager formatManager;
formatManager.registerBasicFormats();
AudioMetadata metadata (myAudioFile, formatManager);
if (metadata.bpm.has_value())
DBG ("BPM: " << *metadata.bpm);
if (metadata.loopStart.has_value() && metadata.loopEnd.has_value())
DBG ("Loop: " << *metadata.loopStart << " to " << *metadata.loopEnd);
AudioMetadata(const juce::File &f, juce::AudioFormatManager &mgr)
Creates an AudioMetadata object by reading metadata from an audio file.
See also
juce::AudioFormatReader, juce::WavAudioFormat, juce::AiffAudioFormat

Constructor & Destructor Documentation

◆ AudioMetadata()

AudioMetadata::AudioMetadata ( const juce::File & f,
juce::AudioFormatManager & mgr )

Creates an AudioMetadata object by reading metadata from an audio file.

Parameters
fThe audio file to read metadata from
mgrAn AudioFormatManager with registered formats (call registerBasicFormats() first)

Member Data Documentation

◆ root

std::optional<int> AudioMetadata::root

The root note (MIDI note number 0-127).

Read from ACID chunk (WAV), sampler chunk MidiUnityNote (WAV), Apple Loops basc chunk (AIFF), or deduced from filename.

◆ bpm

std::optional<float> AudioMetadata::bpm

The tempo in beats per minute.

Calculated from ACID chunk beat count (WAV) or Apple Loops beat count (AIFF), or deduced from filename/cue labels.

◆ numerator

std::optional<int> AudioMetadata::numerator

Time signature numerator (beats per bar).

For example, 4 in a 4/4 time signature. Read from ACID chunk (WAV) or Apple Loops basc chunk (AIFF).

◆ denominator

std::optional<int> AudioMetadata::denominator

Time signature denominator (beat unit).

For example, 4 in a 4/4 time signature. Read from ACID chunk (WAV) or Apple Loops basc chunk (AIFF).

◆ loopStart

std::optional<int64_t> AudioMetadata::loopStart

Loop start point in samples.

Read from WAV sampler chunk (Loop0Start) or AIFF INST chunk via cue point markers.

◆ loopEnd

std::optional<int64_t> AudioMetadata::loopEnd

Loop end point in samples (exclusive).

Read from WAV sampler chunk (Loop0End + 1) or AIFF INST chunk via cue point markers. Only set if within file length.


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