hydrogen 1.1.1
Song Class Reference

Song class. More...

#include <Song.h>

Inheritance diagram for Song:
Object

Public Types

enum  SongMode { PATTERN_MODE , SONG_MODE }
 
enum class  ActionMode { selectMode = 0 , drawMode = 1 }
 Defines the type of user interaction experienced in the SongEditor. More...
 

Public Member Functions

 Song (const QString &sName, const QString &sAuthor, float fBpm, float fVolume)
 
 ~Song ()
 
bool getIsMuted () const
 
void setIsMuted (bool bIsMuted)
 
unsigned getResolution () const
 
void setResolution (unsigned resolution)
 
float getBpm () const
 
void setBpm (float fBpm)
 
const QString & getName () const
 
void setName (const QString &sName)
 
void setVolume (float fVolume)
 
float getVolume () const
 
void setMetronomeVolume (float fVolume)
 
float getMetronomeVolume () const
 
PatternListgetPatternList () const
 
void setPatternList (PatternList *pList)
 
std::vector< PatternList * > * getPatternGroupVector ()
 Return a pointer to a vector storing all Pattern present in the Song. More...
 
const std::vector< PatternList * > * getPatternGroupVector () const
 Return a pointer to a vector storing all Pattern present in the Song. More...
 
void setPatternGroupVector (std::vector< PatternList * > *pGroupVect)
 Sets the vector storing all Pattern present in the Song m_pPatternGroupSequence. More...
 
int lengthInTicks () const
 get the length of the song, in tick units More...
 
bool save (const QString &sFilename)
 Save a song to file. More...
 
void purgeInstrument (Instrument *pInstr)
 Remove all the notes in the song that play on instrument I. More...
 
InstrumentListgetInstrumentList () const
 
void setInstrumentList (InstrumentList *pList)
 
void setNotes (const QString &sNotes)
 
const QString & getNotes () const
 
void setLicense (const QString &sLicense)
 
const QString & getLicense () const
 
void setAuthor (const QString &sAuthor)
 
const QString & getAuthor () const
 
const QString & getFilename () const
 
void setFilename (const QString &sFilename)
 
bool getIsLoopEnabled () const
 
void setIsLoopEnabled (bool bEnabled)
 
float getHumanizeTimeValue () const
 
void setHumanizeTimeValue (float fValue)
 
float getHumanizeVelocityValue () const
 
void setHumanizeVelocityValue (float fValue)
 
float getSwingFactor () const
 
void setSwingFactor (float fFactor)
 
SongMode getMode () const
 
void setMode (SongMode mode)
 
void setIsModified (bool bIsModified)
 
bool getIsModified () const
 
std::vector< DrumkitComponent * > * getComponents () const
 
AutomationPathgetVelocityAutomationPath () const
 
DrumkitComponentgetComponent (int nID) const
 
void readTempPatternList (const QString &sFilename)
 
bool writeTempPatternList (const QString &sFilename)
 
QString copyInstrumentLineToString (int nSelectedPattern, int selectedInstrument)
 
bool pasteInstrumentLineFromString (const QString &sSerialized, int nSelectedPattern, int nSelectedInstrument, std::list< Pattern * > &pPatterns)
 
int getLatestRoundRobin (float fStartVelocity)
 
void setLatestRoundRobin (float fStartVelocity, int nLatestRoundRobin)
 
const QString & getPlaybackTrackFilename () const
 
void setPlaybackTrackFilename (const QString sFilename)
 
bool getPlaybackTrackEnabled () const
 
bool setPlaybackTrackEnabled (const bool bEnabled)
 Specifies whether a playback track should be used. More...
 
float getPlaybackTrackVolume () const
 
void setPlaybackTrackVolume (const float fVolume)
 
ActionMode getActionMode () const
 
void setActionMode (const ActionMode actionMode)
 
bool hasMissingSamples () const
 Song was incompletely loaded from file (missing samples) More...
 
void clearMissingSamples ()
 
void setPanLawType (int nPanLawType)
 
int getPanLawType () const
 
void setPanLawKNorm (float fKNorm)
 
float getPanLawKNorm () const
 
QString toQString (const QString &sPrefix, bool bShort=true) const override
 Formatted string version for debugging purposes. More...
 
- Public Member Functions inherited from Object
 ~Object ()
 destructor More...
 
 Object (const Object &obj)
 copy constructor More...
 
 Object (const char *class_name)
 constructor More...
 
const char * class_name () const
 return the class name More...
 
virtual QString toQString (const QString &sPrefix, bool bShort=true) const
 Formatted string version for debugging purposes. More...
 
void Print (bool bShort=true) const
 Prints content of toQString() via DEBUGLOG. More...
 

Static Public Member Functions

static SonggetEmptySong ()
 Return an empty song. More...
 
static SonggetDefaultSong ()
 Create default song. More...
 
static Songload (const QString &sFilename)
 Load a song from file. More...
 
- Static Public Member Functions inherited from Object
static void set_count (bool flag)
 enable/disable class instances counting More...
 
static bool count_active ()
 return true if class instances counting is enabled More...
 
static unsigned objects_count ()
 return the number of objects More...
 
static void write_objects_map_to (std::ostream &out)
 output the full objects map to a given ostream More...
 
static void write_objects_map_to_cerr ()
 output objects map to stderr More...
 
static int bootstrap (Logger *logger, bool count=false)
 must be called before any Object instantiation ! More...
 
static Loggerlogger ()
 return the logger instance More...
 

Private Attributes

bool m_bIsMuted
 Resolution of the song (number of ticks per quarter) More...
 
unsigned m_resolution
 
float m_fBpm
 Current speed in beats per minutes. More...
 
QString m_sName
 author of the song More...
 
QString m_sAuthor
 volume of the song (0.0..1.0) More...
 
float m_fVolume
 Metronome volume. More...
 
float m_fMetronomeVolume
 
QString m_sNotes
 Pattern list. More...
 
PatternListm_pPatternList
 Sequence of pattern groups. More...
 
std::vector< PatternList * > * m_pPatternGroupSequence
 Instrument list. More...
 
InstrumentListm_pInstrumentList
 list of drumkit component More...
 
std::vector< DrumkitComponent * > * m_pComponents
 
QString m_sFilename
 
bool m_bIsLoopEnabled
 
float m_fHumanizeTimeValue
 
float m_fHumanizeVelocityValue
 
float m_fSwingFactor
 
bool m_bIsModified
 
std::map< float, int > m_latestRoundRobins
 
SongMode m_songMode
 
QString m_sPlaybackTrackFilename
 Name of the file to be loaded as playback track. More...
 
bool m_bPlaybackTrackEnabled
 Whether the playback track should be used at all. More...
 
float m_fPlaybackTrackVolume
 Volume of the playback track. More...
 
AutomationPathm_pVelocityAutomationPath
 license of the song More...
 
QString m_sLicense
 
ActionMode m_actionMode
 Stores the type of interaction with the SongEditor. More...
 
int m_nPanLawType
 
float m_fPanLawKNorm
 

Additional Inherited Members

- Static Public Attributes inherited from Object
static QString sPrintIndention = " "
 String used to format the debugging string output of some core classes. More...
 
- Static Protected Attributes inherited from Object
static Logger__logger = nullptr
 logger instance pointer More...
 

Detailed Description

Song class.

Member Enumeration Documentation

◆ ActionMode

enum class ActionMode
strong

Defines the type of user interaction experienced in the SongEditor.

Enumerator
selectMode 

Holding a pressed left mouse key will draw a rectangle to select a group of Notes.

drawMode 

Holding a pressed left mouse key will draw/delete patterns in all grid cells encountered.

◆ SongMode

enum SongMode
Enumerator
PATTERN_MODE 
SONG_MODE 

Constructor & Destructor Documentation

◆ Song()

Song ( const QString &  sName,
const QString &  sAuthor,
float  fBpm,
float  fVolume 
)

◆ ~Song()

~Song ( )

Member Function Documentation

◆ clearMissingSamples()

void clearMissingSamples ( )

◆ copyInstrumentLineToString()

QString copyInstrumentLineToString ( int  nSelectedPattern,
int  selectedInstrument 
)

◆ getActionMode()

Song::ActionMode getActionMode ( ) const
inline

◆ getAuthor()

const QString & getAuthor ( ) const
inline

◆ getBpm()

float getBpm ( ) const
inline

◆ getComponent()

DrumkitComponent * getComponent ( int  nID) const

◆ getComponents()

std::vector< DrumkitComponent * > * getComponents ( ) const
inline

◆ getDefaultSong()

Song * getDefaultSong ( )
static

Create default song.

◆ getEmptySong()

Song * getEmptySong ( )
static

Return an empty song.

◆ getFilename()

const QString & getFilename ( ) const
inline

◆ getHumanizeTimeValue()

float getHumanizeTimeValue ( ) const
inline

◆ getHumanizeVelocityValue()

float getHumanizeVelocityValue ( ) const
inline

◆ getInstrumentList()

InstrumentList * getInstrumentList ( ) const
inline

◆ getIsLoopEnabled()

bool getIsLoopEnabled ( ) const
inline

◆ getIsModified()

bool getIsModified ( ) const
inline

◆ getIsMuted()

bool getIsMuted ( ) const
inline

◆ getLatestRoundRobin()

int getLatestRoundRobin ( float  fStartVelocity)
inline

◆ getLicense()

const QString & getLicense ( ) const
inline

◆ getMetronomeVolume()

float getMetronomeVolume ( ) const
inline

◆ getMode()

Song::SongMode getMode ( ) const
inline

◆ getName()

const QString & getName ( ) const
inline

◆ getNotes()

const QString & getNotes ( ) const
inline

◆ getPanLawKNorm()

float getPanLawKNorm ( ) const
inline

◆ getPanLawType()

int getPanLawType ( ) const
inline

◆ getPatternGroupVector() [1/2]

std::vector< PatternList * > * getPatternGroupVector ( )
inline

Return a pointer to a vector storing all Pattern present in the Song.

Returns
m_pPatternGroupSequence

◆ getPatternGroupVector() [2/2]

const std::vector< PatternList * > * getPatternGroupVector ( ) const
inline

Return a pointer to a vector storing all Pattern present in the Song.

Returns
m_pPatternGroupSequence

◆ getPatternList()

PatternList * getPatternList ( ) const
inline

◆ getPlaybackTrackEnabled()

bool getPlaybackTrackEnabled ( ) const
inline

◆ getPlaybackTrackFilename()

const QString & getPlaybackTrackFilename ( ) const
inline

◆ getPlaybackTrackVolume()

float getPlaybackTrackVolume ( ) const
inline

◆ getResolution()

unsigned getResolution ( ) const
inline

◆ getSwingFactor()

float getSwingFactor ( ) const
inline

◆ getVelocityAutomationPath()

AutomationPath * getVelocityAutomationPath ( ) const
inline

◆ getVolume()

float getVolume ( ) const
inline

◆ hasMissingSamples()

bool hasMissingSamples ( ) const

Song was incompletely loaded from file (missing samples)

◆ lengthInTicks()

int lengthInTicks ( ) const

get the length of the song, in tick units

◆ load()

Song * load ( const QString &  sFilename)
static

Load a song from file.

◆ pasteInstrumentLineFromString()

bool pasteInstrumentLineFromString ( const QString &  sSerialized,
int  nSelectedPattern,
int  nSelectedInstrument,
std::list< Pattern * > &  pPatterns 
)

◆ purgeInstrument()

void purgeInstrument ( Instrument pInstr)

Remove all the notes in the song that play on instrument I.

The function is real-time safe (it locks the audio data while deleting notes)

◆ readTempPatternList()

void readTempPatternList ( const QString &  sFilename)

◆ save()

bool save ( const QString &  sFilename)

Save a song to file.

◆ setActionMode()

void setActionMode ( const ActionMode  actionMode)

◆ setAuthor()

void setAuthor ( const QString &  sAuthor)
inline

◆ setBpm()

void setBpm ( float  fBpm)

◆ setFilename()

void setFilename ( const QString &  sFilename)
inline

◆ setHumanizeTimeValue()

void setHumanizeTimeValue ( float  fValue)
inline

◆ setHumanizeVelocityValue()

void setHumanizeVelocityValue ( float  fValue)
inline

◆ setInstrumentList()

void setInstrumentList ( InstrumentList pList)
inline

◆ setIsLoopEnabled()

void setIsLoopEnabled ( bool  bEnabled)
inline

◆ setIsModified()

void setIsModified ( bool  bIsModified)

◆ setIsMuted()

void setIsMuted ( bool  bIsMuted)
inline

◆ setLatestRoundRobin()

void setLatestRoundRobin ( float  fStartVelocity,
int  nLatestRoundRobin 
)
inline

◆ setLicense()

void setLicense ( const QString &  sLicense)
inline

◆ setMetronomeVolume()

void setMetronomeVolume ( float  fVolume)
inline

◆ setMode()

void setMode ( Song::SongMode  mode)
inline

◆ setName()

void setName ( const QString &  sName)
inline

◆ setNotes()

void setNotes ( const QString &  sNotes)
inline

◆ setPanLawKNorm()

void setPanLawKNorm ( float  fKNorm)

◆ setPanLawType()

void setPanLawType ( int  nPanLawType)
inline

◆ setPatternGroupVector()

void setPatternGroupVector ( std::vector< PatternList * > *  pGroupVect)
inline

Sets the vector storing all Pattern present in the Song m_pPatternGroupSequence.

Parameters
pGroupVectPointer to a vector containing all Pattern of the Song.

◆ setPatternList()

void setPatternList ( PatternList pList)
inline

◆ setPlaybackTrackEnabled()

bool setPlaybackTrackEnabled ( const bool  bEnabled)
inline

Specifies whether a playback track should be used.

If m_sPlaybackTrackFilename is set to nullptr, m_bPlaybackTrackEnabled will be set to false regardless of the choice in enabled.

Parameters
enabledSets m_bPlaybackTrackEnabled.

◆ setPlaybackTrackFilename()

void setPlaybackTrackFilename ( const QString  sFilename)
inline
Parameters
filenameSets m_sPlaybackTrackFilename.

◆ setPlaybackTrackVolume()

void setPlaybackTrackVolume ( const float  fVolume)
inline
Parameters
volumeSets m_fPlaybackTrackVolume.

◆ setResolution()

void setResolution ( unsigned  resolution)
inline

◆ setSwingFactor()

void setSwingFactor ( float  fFactor)

◆ setVolume()

void setVolume ( float  fVolume)
inline

◆ toQString()

QString toQString ( const QString &  sPrefix,
bool  bShort = true 
) const
overridevirtual

Formatted string version for debugging purposes.

Parameters
sPrefixString prefix which will be added in front of every new line
bShortInstead of the whole content of all classes stored as members just a single unique identifier will be displayed without line breaks.
Returns
String presentation of current object.

Reimplemented from Object.

◆ writeTempPatternList()

bool writeTempPatternList ( const QString &  sFilename)

Field Documentation

◆ m_actionMode

ActionMode m_actionMode
private

Stores the type of interaction with the SongEditor.

◆ m_bIsLoopEnabled

bool m_bIsLoopEnabled
private

◆ m_bIsModified

bool m_bIsModified
private

◆ m_bIsMuted

bool m_bIsMuted
private

Resolution of the song (number of ticks per quarter)

◆ m_bPlaybackTrackEnabled

bool m_bPlaybackTrackEnabled
private

Whether the playback track should be used at all.

It is set by setPlaybackTrackEnabled() and queried by getPlaybackTrackEnabled().

The playback track itself is loaded in Sampler::reinitialize_playback_track().

◆ m_fBpm

float m_fBpm
private

Current speed in beats per minutes.

One of its purposes is an intermediate storage of the tempo at the current transport position in Hydrogen::setTimelineBpm() in order to detect local changes in speed (set by the user). Bounded by [MIN_BPM,MAX_BPM]. song name

◆ m_fHumanizeTimeValue

float m_fHumanizeTimeValue
private

◆ m_fHumanizeVelocityValue

float m_fHumanizeVelocityValue
private

◆ m_fMetronomeVolume

float m_fMetronomeVolume
private

◆ m_fPanLawKNorm

float m_fPanLawKNorm
private

◆ m_fPlaybackTrackVolume

float m_fPlaybackTrackVolume
private

Volume of the playback track.

It is set by setPlaybackTrackVolume() and queried by getPlaybackTrackVolume().

The playback track itself is loaded in Sampler::reinitialize_playback_track().

◆ m_fSwingFactor

float m_fSwingFactor
private

◆ m_fVolume

float m_fVolume
private

Metronome volume.

◆ m_latestRoundRobins

std::map< float, int> m_latestRoundRobins
private

◆ m_nPanLawType

int m_nPanLawType
private

◆ m_pComponents

std::vector<DrumkitComponent*>* m_pComponents
private

◆ m_pInstrumentList

InstrumentList* m_pInstrumentList
private

list of drumkit component

◆ m_pPatternGroupSequence

std::vector<PatternList*>* m_pPatternGroupSequence
private

Instrument list.

◆ m_pPatternList

PatternList* m_pPatternList
private

Sequence of pattern groups.

◆ m_pVelocityAutomationPath

AutomationPath* m_pVelocityAutomationPath
private

license of the song

◆ m_resolution

unsigned m_resolution
private

◆ m_sAuthor

QString m_sAuthor
private

volume of the song (0.0..1.0)

◆ m_sFilename

QString m_sFilename
private

◆ m_sLicense

QString m_sLicense
private

◆ m_sName

QString m_sName
private

author of the song

◆ m_sNotes

QString m_sNotes
private

Pattern list.

◆ m_songMode

SongMode m_songMode
private

◆ m_sPlaybackTrackFilename

QString m_sPlaybackTrackFilename
private

Name of the file to be loaded as playback track.

It is set by setPlaybackTrackFilename() and queried by getPlaybackTrackFilename().

The playback track itself is loaded in Sampler::reinitialize_playback_track().