本文整理汇总了C++中Pattern::insert_note方法的典型用法代码示例。如果您正苦于以下问题:C++ Pattern::insert_note方法的具体用法?C++ Pattern::insert_note怎么用?C++ Pattern::insert_note使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pattern
的用法示例。
在下文中一共展示了Pattern::insert_note方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load_from
Pattern* Pattern::load_from( XMLNode* node, InstrumentList* instruments )
{
Pattern* pattern = new Pattern(
node->read_string( "name", NULL, false, false ),
node->read_string( "info", "", false, false ),
node->read_string( "category", "unknown", false, false ),
node->read_int( "size", -1, false, false )
);
// FIXME support legacy xml element pattern_name, should once be removed
if ( pattern->get_name().isEmpty() ) {
pattern->set_name( node->read_string( "pattern_name", "unknown", false, false ) );
}
XMLNode note_list_node = node->firstChildElement( "noteList" );
if ( !note_list_node.isNull() ) {
XMLNode note_node = note_list_node.firstChildElement( "note" );
while ( !note_node.isNull() ) {
Note* note = Note::load_from( ¬e_node, instruments );
if( note ) {
pattern->insert_note( note );
}
note_node = note_node.nextSiblingElement( "note" );
}
}
return pattern;
}
示例2: loadPattern
Pattern* LocalFileMng::loadPattern( const QString& directory )
{
InstrumentList* instrList = Hydrogen::get_instance()->getSong()->get_instrument_list();
Pattern *pPattern = NULL;
QString patternInfoFile = directory;
QFile check( patternInfoFile );
if (check.exists() == false) {
ERRORLOG( QString("Load Pattern: Data file %1 not found." ).arg( patternInfoFile ) );
return NULL;
}
QDomDocument doc = LocalFileMng::openXmlDocument( patternInfoFile );
QFile file( patternInfoFile );
// root element
QDomNode rootNode = doc.firstChildElement( "drumkit_pattern" ); // root element
if ( rootNode.isNull() ) {
ERRORLOG( "Error reading Pattern: Pattern_drumkit_infonode not found" );
return NULL;
}
QDomNode patternNode = rootNode.firstChildElement( "pattern" );
QString sName( LocalFileMng::readXmlString( patternNode,"pattern_name", "" ) );
QString sInfo( LocalFileMng::readXmlString( patternNode,"info", "" ) );
QString sCategory( LocalFileMng::readXmlString( patternNode,"category", "" ) );
int nSize = -1;
nSize = LocalFileMng::readXmlInt( patternNode, "size",nSize ,false,false );
pPattern = new Pattern( sName, sInfo, sCategory, nSize );
QDomNode pNoteListNode = patternNode.firstChildElement( "noteList" );
if ( ! pNoteListNode.isNull() )
{
// new code :)
QDomNode noteNode = pNoteListNode.firstChildElement( "note" );
while ( ! noteNode.isNull() )
{
Note* pNote = NULL;
unsigned nPosition = LocalFileMng::readXmlInt( noteNode, "position", 0 );
float fLeadLag = LocalFileMng::readXmlFloat( noteNode, "leadlag", 0.0 , false , false);
float fVelocity = LocalFileMng::readXmlFloat( noteNode, "velocity", 0.8f );
float fPan_L = LocalFileMng::readXmlFloat( noteNode, "pan_L", 0.5 );
float fPan_R = LocalFileMng::readXmlFloat( noteNode, "pan_R", 0.5 );
int nLength = LocalFileMng::readXmlInt( noteNode, "length", -1, true );
float nPitch = LocalFileMng::readXmlFloat( noteNode, "pitch", 0.0, false, false );
QString sKey = LocalFileMng::readXmlString( noteNode, "key", "C0", false, false );
QString nNoteOff = LocalFileMng::readXmlString( noteNode, "note_off", "false", false, false );
int instrId = LocalFileMng::readXmlInt( noteNode, "instrument", 0, true );
Instrument *instrRef = instrList->find( instrId );
if ( !instrRef ) {
ERRORLOG( QString( "Instrument with ID: '%1' not found. Note skipped." ).arg( instrId ) );
noteNode = noteNode.nextSiblingElement( "note" );
continue;
}
//assert( instrRef );
bool noteoff = false;
if ( nNoteOff == "true" )
noteoff = true;
pNote = new Note( instrRef, nPosition, fVelocity, fPan_L, fPan_R, nLength, nPitch);
pNote->set_key_octave( sKey );
pNote->set_lead_lag(fLeadLag);
pNote->set_note_off( noteoff );
pPattern->insert_note( pNote );
noteNode = noteNode.nextSiblingElement( "note" );
}
}
return pPattern;
}