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

The SFInstrument class represents an instrument. More...

#include <instrument.hpp>

Public Member Functions

 SFInstrument ()
 Constructs a new empty instrument.
 
 SFInstrument (std::string name)
 Constructs a new empty SFInstrument using the specified name. More...
 
 SFInstrument (std::string name, std::vector< SFInstrumentZone > zones)
 Constructs a new SFInstrument using the specified name and zones. More...
 
 SFInstrument (std::string name, std::vector< SFInstrumentZone > zones, SFInstrumentZone global_zone)
 Constructs a new SFInstrument using the specified name, zones and global zone. More...
 
 SFInstrument (const SFInstrument &origin)
 Constructs a new copy of specified SFInstrument. More...
 
SFInstrumentoperator= (const SFInstrument &origin)
 Copy-assigns a new value to the SFInstrument, replacing its current contents. More...
 
 SFInstrument (SFInstrument &&origin) noexcept
 Acquires the contents of specified SFInstrument. More...
 
SFInstrumentoperator= (SFInstrument &&origin) noexcept
 Move-assigns a new value to the SFInstrument, replacing its current contents. More...
 
 ~SFInstrument ()=default
 Destructs the SFInstrument.
 
const std::string & name () const noexcept
 Returns the name of this instrument. More...
 
void set_name (std::string name)
 Sets the name of this instrument. More...
 
const std::vector< std::unique_ptr< SFInstrumentZone > > & zones () const noexcept
 Returns the list of instrument zones. More...
 
void AddZone (SFInstrumentZone zone)
 Adds an instrument zone to the instrument. More...
 
void RemoveZone (std::vector< std::unique_ptr< SFInstrumentZone >>::const_iterator position)
 Removes an instrument zone from the instrument. More...
 
void RemoveZone (std::vector< std::unique_ptr< SFInstrumentZone >>::const_iterator first, std::vector< std::unique_ptr< SFInstrumentZone >>::const_iterator last)
 Removes instrument zones from the instrument. More...
 
void RemoveZoneIf (std::function< bool(const std::unique_ptr< SFInstrumentZone > &)> predicate)
 Removes instrument zones from the instrument. More...
 
void ClearZones () noexcept
 Removes all of the instrument zones.
 
bool has_global_zone () const noexcept
 Returns true if the instrument has a global zone. More...
 
SFInstrumentZoneglobal_zone () const noexcept
 Returns the global zone. More...
 
void set_global_zone (SFInstrumentZone 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 instrument 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< SFInstrumentNew (Args &&...args)
 Constructs a new SFInstrument. More...
 

Static Public Attributes

static constexpr std::string::size_type kMaxNameLength = 20 - 1
 Maximum length of instrument name (excluding the terminator byte), in terms of bytes.
 

Friends

class SFInstrumentZone
 
class SoundFont
 

Detailed Description

The SFInstrument class represents an instrument.

Remarks
This class represents the official sfInst type.
See also
"7.6 The INST Sub-chunk". In SoundFont Technical Specification 2.04.

Constructor & Destructor Documentation

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

Constructs a new empty SFInstrument using the specified name.

Parameters
namethe name of the instrument.
sf2cute::SFInstrument::SFInstrument ( std::string  name,
std::vector< SFInstrumentZone zones 
)

Constructs a new SFInstrument using the specified name and zones.

Parameters
namethe name of the instrument.
zonesa collection of instrument zones to be assigned to the instrument.
sf2cute::SFInstrument::SFInstrument ( std::string  name,
std::vector< SFInstrumentZone zones,
SFInstrumentZone  global_zone 
)

Constructs a new SFInstrument using the specified name, zones and global zone.

Parameters
namethe name of the instrument.
zonesa collection of instrument zones to be assigned to the instrument.
global_zonea global zone to be assigned to the instrument.
sf2cute::SFInstrument::SFInstrument ( const SFInstrument origin)

Constructs a new copy of specified SFInstrument.

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

Acquires the contents of specified SFInstrument.

Parameters
origina SFInstrument object.

Member Function Documentation

void sf2cute::SFInstrument::AddZone ( SFInstrumentZone  zone)

Adds an instrument zone to the instrument.

Parameters
zonean instrument zone to be assigned to the instrument.
Exceptions
std::invalid_argumentInstrument zone has already been owned by another instrument.
SFInstrumentZone& sf2cute::SFInstrument::global_zone ( ) const
noexcept

Returns the global zone.

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

Returns true if the instrument has a global zone.

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

Returns true if the instrument has a parent file.

Returns
true if the instrument has a parent file.
const std::string& sf2cute::SFInstrument::name ( ) const
noexcept

Returns the name of this instrument.

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

Constructs a new SFInstrument.

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

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

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

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

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

Returns the parent file.

Returns
the parent file.
void sf2cute::SFInstrument::RemoveZone ( std::vector< std::unique_ptr< SFInstrumentZone >>::const_iterator  position)

Removes an instrument zone from the instrument.

Parameters
positionthe instrument zone to remove.
void sf2cute::SFInstrument::RemoveZone ( std::vector< std::unique_ptr< SFInstrumentZone >>::const_iterator  first,
std::vector< std::unique_ptr< SFInstrumentZone >>::const_iterator  last 
)

Removes instrument zones from the instrument.

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

Removes instrument zones from the instrument.

Parameters
predicateunary predicate which returns true if the instrument zone should be removed.
void sf2cute::SFInstrument::set_global_zone ( SFInstrumentZone  global_zone)

Sets the global zone.

Parameters
global_zonethe global zone.
Exceptions
std::invalid_argumentInstrument zone has already been owned by another instrument.
void sf2cute::SFInstrument::set_name ( std::string  name)

Sets the name of this instrument.

Parameters
namethe name of this instrument.
const std::vector<std::unique_ptr<SFInstrumentZone> >& sf2cute::SFInstrument::zones ( ) const
noexcept

Returns the list of instrument zones.

Returns
the list of instrument zones assigned to the instruemnt.

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