SF2cute  0.1
Modern C++ Library for SoundFont 2
sf2cute::SFPreset Class Reference

The SFPreset class represents a preset. More...

#include <preset.hpp>

Public Member Functions

 SFPreset ()
 Constructs a new empty preset.
 
 SFPreset (std::string name)
 Constructs a new empty SFPreset using the specified name. More...
 
 SFPreset (std::string name, uint16_t preset_number, uint16_t bank)
 Constructs a new SFPreset using the specified name and preset numbers. More...
 
 SFPreset (std::string name, uint16_t preset_number, uint16_t bank, std::vector< SFPresetZone > zones)
 Constructs a new SFPreset using the specified name, preset numbers and zones. More...
 
 SFPreset (std::string name, uint16_t preset_number, uint16_t bank, std::vector< SFPresetZone > zones, SFPresetZone global_zone)
 Constructs a new SFPreset using the specified name, preset numbers, zones and global zone. More...
 
 SFPreset (const SFPreset &origin)
 Constructs a new copy of specified SFPreset. More...
 
SFPresetoperator= (const SFPreset &origin)
 Copy-assigns a new value to the SFPreset, replacing its current contents. More...
 
 SFPreset (SFPreset &&origin) noexcept
 Acquires the contents of specified SFPreset. More...
 
SFPresetoperator= (SFPreset &&origin) noexcept
 Move-assigns a new value to the SFPreset, replacing its current contents. More...
 
 ~SFPreset ()=default
 Destructs the SFPreset.
 
const std::string & name () const noexcept
 Returns the name of this preset. More...
 
void set_name (std::string name)
 Sets the name of this preset. More...
 
uint16_t preset_number () const noexcept
 Returns the preset number. More...
 
void set_preset_number (uint16_t preset_number)
 Sets the preset number. More...
 
uint16_t bank () const noexcept
 Returns the bank number. More...
 
void set_bank (uint16_t bank)
 Sets the bank number. More...
 
uint32_t library () const noexcept
 Returns the library. More...
 
void set_library (uint32_t library)
 Sets the library. More...
 
uint32_t genre () const noexcept
 Returns the genre. More...
 
void set_genre (uint32_t genre)
 Sets the genre. More...
 
uint32_t morphology () const noexcept
 Returns the morphology. More...
 
void set_morphology (uint32_t morphology)
 Sets the morphology. More...
 
const std::vector< std::unique_ptr< SFPresetZone > > & zones () const noexcept
 Returns the list of preset zones. More...
 
void AddZone (SFPresetZone zone)
 Adds a preset zone to the preset. More...
 
void RemoveZone (std::vector< std::unique_ptr< SFPresetZone >>::const_iterator position)
 Removes a preset zone from the preset. More...
 
void RemoveZone (std::vector< std::unique_ptr< SFPresetZone >>::const_iterator first, std::vector< std::unique_ptr< SFPresetZone >>::const_iterator last)
 Removes preset zones from the preset. More...
 
void RemoveZoneIf (std::function< bool(const std::unique_ptr< SFPresetZone > &)> predicate)
 Removes preset zones from the preset. More...
 
void ClearZones () noexcept
 Removes all of the preset zones.
 
bool has_global_zone () const noexcept
 Returns true if the preset has a global zone. More...
 
SFPresetZoneglobal_zone () const noexcept
 Returns the global zone. More...
 
void set_global_zone (SFPresetZone global_zone)
 Sets the global zone. More...
 
void reset_global_zone () noexcept
 Resets the global zone.
 
bool has_parent_file () const noexcept
 Returns true if the preset has a parent file. More...
 
SoundFontparent_file () const noexcept
 Returns the parent file. More...
 

Static Public Member Functions

template<typename... Args>
static std::shared_ptr< SFPresetNew (Args &&...args)
 Constructs a new SFPreset. More...
 

Static Public Attributes

static constexpr uint16_t kPercussionBank = 128
 The bank number for General MIDI drums.
 
static constexpr std::string::size_type kMaxNameLength = 20 - 1
 Maximum length of preset name (excluding the terminator byte), in terms of bytes.
 

Friends

class SFPresetZone
 
class SoundFont
 

Detailed Description

The SFPreset class represents a preset.

Remarks
This class represents the official sfPresetHeader type.
See also
"7.2 The PHDR Sub-chunk". In SoundFont Technical Specification 2.04.

Constructor & Destructor Documentation

sf2cute::SFPreset::SFPreset ( std::string  name)
explicit

Constructs a new empty SFPreset using the specified name.

Parameters
namethe name of the preset.
sf2cute::SFPreset::SFPreset ( std::string  name,
uint16_t  preset_number,
uint16_t  bank 
)

Constructs a new SFPreset using the specified name and preset numbers.

Parameters
namethe name of the preset.
preset_numberthe preset number.
bankthe bank number.
sf2cute::SFPreset::SFPreset ( std::string  name,
uint16_t  preset_number,
uint16_t  bank,
std::vector< SFPresetZone zones 
)

Constructs a new SFPreset using the specified name, preset numbers and zones.

Parameters
namethe name of the preset.
preset_numberthe preset number.
bankthe bank number.
zonesa collection of preset zones to be assigned to the preset.
sf2cute::SFPreset::SFPreset ( std::string  name,
uint16_t  preset_number,
uint16_t  bank,
std::vector< SFPresetZone zones,
SFPresetZone  global_zone 
)

Constructs a new SFPreset using the specified name, preset numbers, zones and global zone.

Parameters
namethe name of the preset.
preset_numberthe preset number.
bankthe bank number.
zonesa collection of preset zones to be assigned to the preset.
global_zonea global zone to be assigned to the preset.
sf2cute::SFPreset::SFPreset ( const SFPreset origin)

Constructs a new copy of specified SFPreset.

Parameters
origina SFPreset object.
sf2cute::SFPreset::SFPreset ( SFPreset &&  origin)
noexcept

Acquires the contents of specified SFPreset.

Parameters
origina SFPreset object.

Member Function Documentation

void sf2cute::SFPreset::AddZone ( SFPresetZone  zone)

Adds a preset zone to the preset.

Parameters
zonea preset zone to be assigned to the preset.
Exceptions
std::invalid_argumentPreset zone has already been owned by another preset.
uint16_t sf2cute::SFPreset::bank ( ) const
noexcept

Returns the bank number.

Returns
the bank number.
uint32_t sf2cute::SFPreset::genre ( ) const
noexcept

Returns the genre.

Returns
the genre.
Remarks
The genre field represents the unused dwGenre field of sfPresetHeader type.
SFPresetZone& sf2cute::SFPreset::global_zone ( ) const
noexcept

Returns the global zone.

Returns
the global zone.
bool sf2cute::SFPreset::has_global_zone ( ) const
noexcept

Returns true if the preset has a global zone.

Returns
true if the preset has a global zone.
bool sf2cute::SFPreset::has_parent_file ( ) const
noexcept

Returns true if the preset has a parent file.

Returns
true if the preset has a parent file.
uint32_t sf2cute::SFPreset::library ( ) const
noexcept

Returns the library.

Returns
the library.
Remarks
The library field represents the unused dwLibrary field of sfPresetHeader type.
uint32_t sf2cute::SFPreset::morphology ( ) const
noexcept

Returns the morphology.

Returns
the morphology.
Remarks
The morphology field represents the unused dwMorphology field of sfPresetHeader type.
const std::string& sf2cute::SFPreset::name ( ) const
noexcept

Returns the name of this preset.

Returns
the name of this preset.
template<typename... Args>
static std::shared_ptr<SFPreset> sf2cute::SFPreset::New ( Args &&...  args)
inlinestatic

Constructs a new SFPreset.

Parameters
argsthe arguments for the SFPreset constructor.
Returns
the new SFPreset object.
SFPreset& sf2cute::SFPreset::operator= ( const SFPreset origin)

Copy-assigns a new value to the SFPreset, replacing its current contents.

Parameters
origina SFPreset object.
SFPreset& sf2cute::SFPreset::operator= ( SFPreset &&  origin)
noexcept

Move-assigns a new value to the SFPreset, replacing its current contents.

Parameters
origina SFPreset object.
SoundFont& sf2cute::SFPreset::parent_file ( ) const
noexcept

Returns the parent file.

Returns
the parent file.
uint16_t sf2cute::SFPreset::preset_number ( ) const
noexcept

Returns the preset number.

Returns
the preset number.
void sf2cute::SFPreset::RemoveZone ( std::vector< std::unique_ptr< SFPresetZone >>::const_iterator  position)

Removes a preset zone from the preset.

Parameters
positionthe preset zone to remove.
void sf2cute::SFPreset::RemoveZone ( std::vector< std::unique_ptr< SFPresetZone >>::const_iterator  first,
std::vector< std::unique_ptr< SFPresetZone >>::const_iterator  last 
)

Removes preset zones from the preset.

Parameters
firstthe first preset zone to remove.
lastthe last preset zone to remove.
void sf2cute::SFPreset::RemoveZoneIf ( std::function< bool(const std::unique_ptr< SFPresetZone > &)>  predicate)

Removes preset zones from the preset.

Parameters
predicateunary predicate which returns true if the preset zone should be removed.
void sf2cute::SFPreset::set_bank ( uint16_t  bank)

Sets the bank number.

Parameters
bankthe bank number.
void sf2cute::SFPreset::set_genre ( uint32_t  genre)

Sets the genre.

Parameters
genrethe genre.
Remarks
The genre field represents the unused dwGenre field of sfPresetHeader type.
void sf2cute::SFPreset::set_global_zone ( SFPresetZone  global_zone)

Sets the global zone.

Parameters
global_zonethe global zone.
Exceptions
std::invalid_argumentPreset zone has already been owned by another preset.
void sf2cute::SFPreset::set_library ( uint32_t  library)

Sets the library.

Parameters
librarythe library.
Remarks
The library field represents the unused dwLibrary field of sfPresetHeader type.
void sf2cute::SFPreset::set_morphology ( uint32_t  morphology)

Sets the morphology.

Parameters
morphologythe morphology.
Remarks
The morphology field represents the unused dwMorphology field of sfPresetHeader type.
void sf2cute::SFPreset::set_name ( std::string  name)

Sets the name of this preset.

Parameters
namethe name of this preset.
void sf2cute::SFPreset::set_preset_number ( uint16_t  preset_number)

Sets the preset number.

Parameters
preset_numberthe preset number.
const std::vector<std::unique_ptr<SFPresetZone> >& sf2cute::SFPreset::zones ( ) const
noexcept

Returns the list of preset zones.

Returns
the list of preset zones assigned to the preset.

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