RADLib
RADical C++ application framework
RADMedia::MidiSynthesizer Class Reference

#include <RADMedia.h>

Public Member Functions

 MidiSynthesizer ()
 Creates a closed synthesizer. More...
 
 ~MidiSynthesizer ()
 Releases the native synth backend if open. More...
 
 MidiSynthesizer (const MidiSynthesizer &)=delete
 Synthesizers own native backend state and are move-only. More...
 
MidiSynthesizeroperator= (const MidiSynthesizer &)=delete
 Synthesizers own native backend state and are move-only. More...
 
 MidiSynthesizer (MidiSynthesizer &&) noexcept
 Moves a synthesizer. More...
 
MidiSynthesizeroperator= (MidiSynthesizer &&) noexcept
 Moves a synthesizer. More...
 
bool open (uint32_t sampleRate=48000, float gain=0.2f, std::string *error=nullptr)
 Opens or reopens the synth at sampleRate and gain. More...
 
void close ()
 Closes the synth and unloads native resources. More...
 
bool isOpen () const
 Returns true when native synth resources are open. More...
 
uint32_t sampleRate () const
 Returns the current synth sample rate. More...
 
bool loadSoundFont (const std::string &path, bool resetPresets=true, std::string *error=nullptr)
 Loads a SoundFont into the synth, optionally resetting presets. More...
 
std::optional< AudioBufferrender (const MidiClip &clip, std::string *error=nullptr)
 Renders clip to interleaved Float32 audio. More...
 
bool beginStream (const MidiClip &clip, std::string *error=nullptr)
 Starts stateful small-buffer rendering for clip. More...
 
std::optional< AudioBufferrenderNext (size_t maxFrames, std::string *error=nullptr)
 Renders the next streaming block. Empty buffer means end of stream. More...
 
bool streamFinished () const
 Returns true once a stream has no more frames to render. More...
 

Static Public Member Functions

static bool isAvailable ()
 Returns true when RADMedia can render MIDI preview audio. More...
 
static std::vector< std::string > defaultSoundFontPaths ()
 Returns existing common system SoundFont paths. More...
 
static std::optional< AudioBufferrenderClip (const MidiClip &clip, const std::string &soundFontPath, std::string *error=nullptr)
 Convenience helper that opens, loads soundFontPath, renders clip, and closes. More...
 

Detailed Description

Backend-neutral MIDI preview renderer facade.

RADMedia includes a lightweight built-in MIDI preview renderer so applications can play edited clips without depending on FluidSynth. Loading a SoundFont validates/selects the preset source for track configuration; richer SF2/SF3 sample playback can be attached later behind this same facade.

Constructor & Destructor Documentation

◆ MidiSynthesizer() [1/3]

RADMedia::MidiSynthesizer::MidiSynthesizer ( )

Creates a closed synthesizer.

◆ ~MidiSynthesizer()

RADMedia::MidiSynthesizer::~MidiSynthesizer ( )

Releases the native synth backend if open.

◆ MidiSynthesizer() [2/3]

RADMedia::MidiSynthesizer::MidiSynthesizer ( const MidiSynthesizer )
delete

Synthesizers own native backend state and are move-only.

◆ MidiSynthesizer() [3/3]

RADMedia::MidiSynthesizer::MidiSynthesizer ( MidiSynthesizer &&  )
noexcept

Moves a synthesizer.

Member Function Documentation

◆ beginStream()

bool RADMedia::MidiSynthesizer::beginStream ( const MidiClip clip,
std::string *  error = nullptr 
)

Starts stateful small-buffer rendering for clip.

◆ close()

void RADMedia::MidiSynthesizer::close ( )

Closes the synth and unloads native resources.

◆ defaultSoundFontPaths()

static std::vector<std::string> RADMedia::MidiSynthesizer::defaultSoundFontPaths ( )
static

Returns existing common system SoundFont paths.

◆ isAvailable()

static bool RADMedia::MidiSynthesizer::isAvailable ( )
static

Returns true when RADMedia can render MIDI preview audio.

◆ isOpen()

bool RADMedia::MidiSynthesizer::isOpen ( ) const

Returns true when native synth resources are open.

◆ loadSoundFont()

bool RADMedia::MidiSynthesizer::loadSoundFont ( const std::string &  path,
bool  resetPresets = true,
std::string *  error = nullptr 
)

Loads a SoundFont into the synth, optionally resetting presets.

◆ open()

bool RADMedia::MidiSynthesizer::open ( uint32_t  sampleRate = 48000,
float  gain = 0.2f,
std::string *  error = nullptr 
)

Opens or reopens the synth at sampleRate and gain.

◆ operator=() [1/2]

MidiSynthesizer& RADMedia::MidiSynthesizer::operator= ( const MidiSynthesizer )
delete

Synthesizers own native backend state and are move-only.

◆ operator=() [2/2]

MidiSynthesizer& RADMedia::MidiSynthesizer::operator= ( MidiSynthesizer &&  )
noexcept

Moves a synthesizer.

◆ render()

std::optional<AudioBuffer> RADMedia::MidiSynthesizer::render ( const MidiClip clip,
std::string *  error = nullptr 
)

Renders clip to interleaved Float32 audio.

◆ renderClip()

static std::optional<AudioBuffer> RADMedia::MidiSynthesizer::renderClip ( const MidiClip clip,
const std::string &  soundFontPath,
std::string *  error = nullptr 
)
static

Convenience helper that opens, loads soundFontPath, renders clip, and closes.

◆ renderNext()

std::optional<AudioBuffer> RADMedia::MidiSynthesizer::renderNext ( size_t  maxFrames,
std::string *  error = nullptr 
)

Renders the next streaming block. Empty buffer means end of stream.

◆ sampleRate()

uint32_t RADMedia::MidiSynthesizer::sampleRate ( ) const

Returns the current synth sample rate.

◆ streamFinished()

bool RADMedia::MidiSynthesizer::streamFinished ( ) const

Returns true once a stream has no more frames to render.


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