SDL_audiolib 0.0.0
An audio decoding, resampling and mixing library
Aulib::DecoderAdlmidi Class Reference

libADLMIDI decoder. More...

#include <DecoderAdlmidi.h>

Inheritance diagram for Aulib::DecoderAdlmidi:
Aulib::Decoder

Public Types

enum class  Emulator {
  Nuked , Nuked_174 , Dosbox , Opal ,
  Java
}
 

Public Member Functions

 DecoderAdlmidi ()
 
 ~DecoderAdlmidi () override
 
auto setEmulator (Emulator emulator) -> bool
 Set OPL emulator. More...
 
auto setChipAmount (int chip_amount) -> bool
 Set amount of emulated OPL chips. More...
 
auto loadBank (SDL_RWops *rwops) -> bool
 Load and set an FM patch bank. More...
 
auto loadBank (const std::string &filename) -> bool
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
auto loadEmbeddedBank (int bank_number) -> bool
 Load and set one of the FM patch banks embedded in libADLMIDI. More...
 
auto open (SDL_RWops *rwops) -> bool override
 
auto getChannels () const -> int override
 
auto getRate () const -> int override
 
auto rewind () -> bool override
 
auto duration () const -> std::chrono::microseconds override
 
auto seekToTime (std::chrono::microseconds pos) -> bool override
 
- Public Member Functions inherited from Aulib::Decoder
 Decoder ()
 
virtual ~Decoder ()
 
 Decoder (const Decoder &)=delete
 
auto operator= (const Decoder &) -> Decoder &=delete
 
auto isOpen () const -> bool
 
auto decode (float buf[], int len, bool &callAgain) -> int
 
virtual auto open (SDL_RWops *rwops) -> bool=0
 
virtual auto getChannels () const -> int=0
 
virtual auto getRate () const -> int=0
 
virtual auto rewind () -> bool=0
 
virtual auto duration () const -> std::chrono::microseconds=0
 
virtual auto seekToTime (std::chrono::microseconds pos) -> bool=0
 

Static Public Member Functions

static auto getEmbeddedBanks () -> const std::vector< std::string > &
 Get a list of all libADLMIDI embedded FM patch banks. More...
 
- Static Public Member Functions inherited from Aulib::Decoder
template<class... Decoders>
static auto decoderFor (const std::string &filename) -> std::unique_ptr< Decoder >
 Find and return an instance of the first decoder that can open the specified file. More...
 
template<class... Decoders>
static auto decoderFor (SDL_RWops *rwops) -> std::unique_ptr< Decoder >
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
static auto decoderFor (const std::string &filename) -> std::unique_ptr< Decoder >
 Find and return an instance of the first decoder that can open the specified file. More...
 
static auto decoderFor (SDL_RWops *rwops) -> std::unique_ptr< Decoder >
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 

Protected Member Functions

auto doDecoding (float buf[], int len, bool &callAgain) -> int override
 
- Protected Member Functions inherited from Aulib::Decoder
void setIsOpen (bool f)
 
virtual auto doDecoding (float buf[], int len, bool &callAgain) -> int=0
 

Detailed Description

libADLMIDI decoder.

This decoder always generates samples at 49716Hz, the native rate of the OPL synths provided by libADLMIDI.

Member Enumeration Documentation

◆ Emulator

Enumerator
Nuked 
Nuked_174 
Dosbox 
Opal 
Java 

Constructor & Destructor Documentation

◆ DecoderAdlmidi()

Aulib::DecoderAdlmidi::DecoderAdlmidi ( )

◆ ~DecoderAdlmidi()

Aulib::DecoderAdlmidi::~DecoderAdlmidi ( )
override

Member Function Documentation

◆ doDecoding()

auto Aulib::DecoderAdlmidi::doDecoding ( float  buf[],
int  len,
bool &  callAgain 
) -> int
overrideprotectedvirtual

Implements Aulib::Decoder.

◆ duration()

auto Aulib::DecoderAdlmidi::duration ( ) const -> std::chrono::microseconds
overridevirtual

Implements Aulib::Decoder.

◆ getChannels()

auto Aulib::DecoderAdlmidi::getChannels ( ) const -> int
overridevirtual

Implements Aulib::Decoder.

◆ getEmbeddedBanks()

static auto Aulib::DecoderAdlmidi::getEmbeddedBanks ( ) -> const std::vector< std::string > &
static

Get a list of all libADLMIDI embedded FM patch banks.

If libADLMIDI was built without embedded banks, the list will be empty. To use one of these banks, pass its index to loadEmbeddedBank().

Returns
List of embedded banks.

◆ getRate()

auto Aulib::DecoderAdlmidi::getRate ( ) const -> int
overridevirtual

Implements Aulib::Decoder.

◆ loadBank() [1/2]

auto Aulib::DecoderAdlmidi::loadBank ( const std::string &  filename) -> bool

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ loadBank() [2/2]

auto Aulib::DecoderAdlmidi::loadBank ( SDL_RWops *  rwops) -> bool

Load and set an FM patch bank.

The data must be in a format that libADLMIDI understands. At the time of this writing, this means WOPL3. If there's an already loaded bank, it will be replaced by the new one. Ownership of the rwops is transfered to the decoder.

The bank will be set immediately if the decoder is open. Otherwise, it will be set when open() is called.

Returns
true on success, false otherwise.

◆ loadEmbeddedBank()

auto Aulib::DecoderAdlmidi::loadEmbeddedBank ( int  bank_number) -> bool

Load and set one of the FM patch banks embedded in libADLMIDI.

By default, libADLMIDI comes with a set of embedded FM patch banks. These can be disabled when building libADLMIDI, in which case this function will always fail. Use getEmbeddedBanks() to get a list of all embedded banks. If there's an already loaded bank, it will be replaced by the new one.

The bank will be set immediately if the decoder is open. Otherwise, it will be set when open() is called.

Returns
true on success, false otherwise.

◆ open()

auto Aulib::DecoderAdlmidi::open ( SDL_RWops *  rwops) -> bool
overridevirtual

Implements Aulib::Decoder.

◆ rewind()

auto Aulib::DecoderAdlmidi::rewind ( ) -> bool
overridevirtual

Implements Aulib::Decoder.

◆ seekToTime()

auto Aulib::DecoderAdlmidi::seekToTime ( std::chrono::microseconds  pos) -> bool
overridevirtual

Implements Aulib::Decoder.

◆ setChipAmount()

auto Aulib::DecoderAdlmidi::setChipAmount ( int  chip_amount) -> bool

Set amount of emulated OPL chips.

By default, 6 chips will be emulated, which should provide a high enough polyphony without note dropouts with most FM banks. However, the needed chip amount might be higher with some FM banks, in which case you can use a higher amount of chips.

The chip amount will be changed immediately if the decoder is open. Otherwise, it will be changed when open() is called.

Returns
true on success, false otherwise.

◆ setEmulator()

auto Aulib::DecoderAdlmidi::setEmulator ( Emulator  emulator) -> bool

Set OPL emulator.

If you don't call this function, libADLMIDI will use whatever emulator it uses by default. Which one that is, is not specified. Note that libADLMIDI might have been built without all of the emulators. Trying to set an emulator that is missing will fail.

The emulator will be set immediately if the decoder is open. Otherwise, it will be set when open() is called.

Returns
true on success, false otherwise.