Gin
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
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< introot
 The root note (MIDI note number 0-127).
 
std::optional< floatbpm
 The tempo in beats per minute.
 
std::optional< intnumerator
 Time signature numerator (beats per bar).
 
std::optional< intdenominator
 Time signature denominator (beat unit).
 
std::optional< int64_tloopStart
 Loop start point in samples.
 
std::optional< int64_tloopEnd
 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:

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

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();
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);
Extracts musical metadata from audio files.
Definition gin_audiometadata.h:43
A lightweight 2D point class for projects that don't use juce_graphics.
Definition gin_point.h:25
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: