本文整理汇总了C++中Pattern::get_info方法的典型用法代码示例。如果您正苦于以下问题:C++ Pattern::get_info方法的具体用法?C++ Pattern::get_info怎么用?C++ Pattern::get_info使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pattern
的用法示例。
在下文中一共展示了Pattern::get_info方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: newPatBtnClicked
///
/// Create a new pattern
///
void SongEditorPanel::newPatBtnClicked( Button* btn )
{
UNUSED( btn );
Hydrogen *pEngine = Hydrogen::get_instance();
Song *pSong = pEngine->getSong();
PatternList *pPatternList = pSong->get_pattern_list();
Pattern *pNewPattern = new Pattern( trUtf8("Pattern %1").arg(pPatternList->size()+1));
PatternPropertiesDialog *pDialog = new PatternPropertiesDialog( this, pNewPattern, 0, true );
if ( pDialog->exec() == QDialog::Accepted ) {
SE_addEmptyPatternAction*action =
new SE_addEmptyPatternAction( pNewPattern->get_name() , pNewPattern->get_info(), pNewPattern->get_category(), pEngine->getSelectedPatternNumber()+1);
HydrogenApp::get_instance()->m_undoStack->push( action );
}
delete pNewPattern;
delete pDialog;
}
示例2: copyInstrumentLineToString
QString LocalFileMng::copyInstrumentLineToString(Song *song, int selectedPattern, int selectedInstrument)
{
Instrument *instr = song->get_instrument_list()->get( selectedInstrument );
assert( instr );
QDomDocument doc;
QDomProcessingInstruction header = doc.createProcessingInstruction( "xml", "version=\"1.0\" encoding=\"UTF-8\"");
doc.appendChild( header );
QDomNode rootNode = doc.createElement( "instrument_line" );
//LIB_ID just in work to get better usability
//writeXmlString( &rootNode, "LIB_ID", "in_work" );
writeXmlString( rootNode, "author", song->get_author() );
writeXmlString( rootNode, "license", song->get_license() );
QDomNode patternList = doc.createElement( "patternList" );
unsigned nPatterns = song->get_pattern_list()->size();
for ( unsigned i = 0; i < nPatterns; i++ )
{
if ((selectedPattern >= 0) && (selectedPattern != i))
continue;
// Export pattern
Pattern *pat = song->get_pattern_list()->get( i );
QDomNode patternNode = doc.createElement( "pattern" );
writeXmlString( patternNode, "pattern_name", pat->get_name() );
QString category;
if ( pat->get_category().isEmpty() )
category = "No category";
else
category = pat->get_category();
writeXmlString( patternNode, "info", pat->get_info() );
writeXmlString( patternNode, "category", category );
writeXmlString( patternNode, "size", QString("%1").arg( pat->get_length() ) );
QDomNode noteListNode = doc.createElement( "noteList" );
const Pattern::notes_t* notes = pat->get_notes();
FOREACH_NOTE_CST_IT_BEGIN_END(notes,it)
{
Note *pNote = it->second;
assert( pNote );
// Export only specified instrument
if (pNote->get_instrument() == instr)
{
QDomNode noteNode = doc.createElement( "note" );
writeXmlString( noteNode, "position", QString("%1").arg( pNote->get_position() ) );
writeXmlString( noteNode, "leadlag", QString("%1").arg( pNote->get_lead_lag() ) );
writeXmlString( noteNode, "velocity", QString("%1").arg( pNote->get_velocity() ) );
writeXmlString( noteNode, "pan_L", QString("%1").arg( pNote->get_pan_l() ) );
writeXmlString( noteNode, "pan_R", QString("%1").arg( pNote->get_pan_r() ) );
writeXmlString( noteNode, "pitch", QString("%1").arg( pNote->get_pitch() ) );
writeXmlString( noteNode, "key", pNote->key_to_string() );
writeXmlString( noteNode, "length", QString("%1").arg( pNote->get_length() ) );
noteListNode.appendChild( noteNode );
}
}
patternNode.appendChild( noteListNode );
patternList.appendChild( patternNode );
}
示例3: writeSong
//.........这里部分代码省略.........
InstrumentLayer *pLayer = pComponent->get_layer( nLayer );
if ( pLayer == NULL ) continue;
Sample *pSample = pLayer->get_sample();
if ( pSample == NULL ) continue;
bool sIsModified = pSample->get_is_modified();
Sample::Loops lo = pSample->get_loops();
Sample::Rubberband ro = pSample->get_rubberband();
QString sMode = pSample->get_loop_mode_string();
QDomNode layerNode = doc.createElement( "layer" );
LocalFileMng::writeXmlString( layerNode, "filename", Filesystem::prepare_sample_path( pSample->get_filepath() ) );
LocalFileMng::writeXmlBool( layerNode, "ismodified", sIsModified);
LocalFileMng::writeXmlString( layerNode, "smode", pSample->get_loop_mode_string() );
LocalFileMng::writeXmlString( layerNode, "startframe", QString("%1").arg( lo.start_frame ) );
LocalFileMng::writeXmlString( layerNode, "loopframe", QString("%1").arg( lo.loop_frame ) );
LocalFileMng::writeXmlString( layerNode, "loops", QString("%1").arg( lo.count ) );
LocalFileMng::writeXmlString( layerNode, "endframe", QString("%1").arg( lo.end_frame ) );
LocalFileMng::writeXmlString( layerNode, "userubber", QString("%1").arg( ro.use ) );
LocalFileMng::writeXmlString( layerNode, "rubberdivider", QString("%1").arg( ro.divider ) );
LocalFileMng::writeXmlString( layerNode, "rubberCsettings", QString("%1").arg( ro.c_settings ) );
LocalFileMng::writeXmlString( layerNode, "rubberPitch", QString("%1").arg( ro.pitch ) );
LocalFileMng::writeXmlString( layerNode, "min", QString("%1").arg( pLayer->get_start_velocity() ) );
LocalFileMng::writeXmlString( layerNode, "max", QString("%1").arg( pLayer->get_end_velocity() ) );
LocalFileMng::writeXmlString( layerNode, "gain", QString("%1").arg( pLayer->get_gain() ) );
LocalFileMng::writeXmlString( layerNode, "pitch", QString("%1").arg( pLayer->get_pitch() ) );
Sample::VelocityEnvelope* velocity = pSample->get_velocity_envelope();
for (int y = 0; y < velocity->size(); y++){
QDomNode volumeNode = doc.createElement( "volume" );
LocalFileMng::writeXmlString( volumeNode, "volume-position", QString("%1").arg( velocity->at(y).frame ) );
LocalFileMng::writeXmlString( volumeNode, "volume-value", QString("%1").arg( velocity->at(y).value ) );
layerNode.appendChild( volumeNode );
}
Sample::PanEnvelope* pan = pSample->get_pan_envelope();
for (int y = 0; y < pan->size(); y++){
QDomNode panNode = doc.createElement( "pan" );
LocalFileMng::writeXmlString( panNode, "pan-position", QString("%1").arg( pan->at(y).frame ) );
LocalFileMng::writeXmlString( panNode, "pan-value", QString("%1").arg( pan->at(y).value ) );
layerNode.appendChild( panNode );
}
componentNode.appendChild( layerNode );
}
instrumentNode.appendChild( componentNode );
}
instrumentListNode.appendChild( instrumentNode );
}
songNode.appendChild( instrumentListNode );
// pattern list
QDomNode patternListNode = doc.createElement( "patternList" );
unsigned nPatterns = song->get_pattern_list()->size();
for ( unsigned i = 0; i < nPatterns; i++ ) {
Pattern *pat = song->get_pattern_list()->get( i );
// pattern
QDomNode patternNode = doc.createElement( "pattern" );
LocalFileMng::writeXmlString( patternNode, "name", pat->get_name() );
LocalFileMng::writeXmlString( patternNode, "category", pat->get_category() );
LocalFileMng::writeXmlString( patternNode, "size", QString("%1").arg( pat->get_length() ) );
LocalFileMng::writeXmlString( patternNode, "info", pat->get_info() );
QDomNode noteListNode = doc.createElement( "noteList" );
const Pattern::notes_t* notes = pat->get_notes();
FOREACH_NOTE_CST_IT_BEGIN_END(notes,it) {
Note *pNote = it->second;
assert( pNote );
QDomNode noteNode = doc.createElement( "note" );
LocalFileMng::writeXmlString( noteNode, "position", QString("%1").arg( pNote->get_position() ) );
LocalFileMng::writeXmlString( noteNode, "leadlag", QString("%1").arg( pNote->get_lead_lag() ) );
LocalFileMng::writeXmlString( noteNode, "velocity", QString("%1").arg( pNote->get_velocity() ) );
LocalFileMng::writeXmlString( noteNode, "pan_L", QString("%1").arg( pNote->get_pan_l() ) );
LocalFileMng::writeXmlString( noteNode, "pan_R", QString("%1").arg( pNote->get_pan_r() ) );
LocalFileMng::writeXmlString( noteNode, "pitch", QString("%1").arg( pNote->get_pitch() ) );
LocalFileMng::writeXmlString( noteNode, "probability", QString("%1").arg( pNote->get_probability() ) );
LocalFileMng::writeXmlString( noteNode, "key", pNote->key_to_string() );
LocalFileMng::writeXmlString( noteNode, "length", QString("%1").arg( pNote->get_length() ) );
LocalFileMng::writeXmlString( noteNode, "instrument", QString("%1").arg( pNote->get_instrument()->get_id() ) );
QString noteoff = "false";
if ( pNote->get_note_off() ) noteoff = "true";
LocalFileMng::writeXmlString( noteNode, "note_off", noteoff );
noteListNode.appendChild( noteNode );
}
patternNode.appendChild( noteListNode );
patternListNode.appendChild( patternNode );
}
示例4: savePattern
int LocalFileMng::savePattern( Song *song , const QString& drumkit_name, int selectedpattern , const QString& patternname, const QString& realpatternname, int mode)
{
//int mode = 1 save, int mode = 2 save as
// INSTRUMENT NODE
Instrument *instr = song->get_instrument_list()->get( 0 );
assert( instr );
Pattern *pat = song->get_pattern_list()->get( selectedpattern );
QString sPatternDir = Preferences::get_instance()->getDataDirectory() + "patterns/" + drumkit_name;
INFOLOG( "[savePattern]" + sPatternDir );
// check if the directory exists
QDir dir( sPatternDir );
QDir dirPattern( sPatternDir );
if ( !dir.exists() ) {
dir.mkdir( sPatternDir );// create the drumkit directory
}
QString sPatternXmlFilename;
// create the drumkit.xml file
switch ( mode ){
case 1: //save
sPatternXmlFilename = sPatternDir + "/" + QString( patternname + QString( ".h2pattern" ));
break;
case 2: //save as
sPatternXmlFilename = patternname;
break;
case 3: //"save" but overwrite a existing pattern. mode 3 disable the last file exist check
sPatternXmlFilename = sPatternDir + "/" + QString( patternname + QString( ".h2pattern" ));
break;
case 4: //tmp pattern needed by undo/redo
sPatternXmlFilename = patternname;
default:
WARNINGLOG( "Pattern Save unknown status");
break;
}
//test if the file exists
QFile testfile( sPatternXmlFilename );
if ( testfile.exists() && mode == 1)
return 1;
QDomDocument doc;
QDomProcessingInstruction header = doc.createProcessingInstruction( "xml", "version=\"1.0\" encoding=\"UTF-8\"");
doc.appendChild( header );
QDomNode rootNode = doc.createElement( "drumkit_pattern" );
//LIB_ID just in work to get better usability
//writeXmlString( &rootNode, "LIB_ID", "in_work" );
writeXmlString( rootNode, "pattern_for_drumkit", drumkit_name );
writeXmlString( rootNode, "author", song->get_author() );
writeXmlString( rootNode, "license", song->get_license() );
// pattern
QDomNode patternNode = doc.createElement( "pattern" );
writeXmlString( patternNode, "pattern_name", realpatternname );
QString category;
if ( pat->get_category().isEmpty() )
category = "No category";
else
category = pat->get_category();
writeXmlString( patternNode, "info", pat->get_info() );
writeXmlString( patternNode, "category", category );
writeXmlString( patternNode, "size", QString("%1").arg( pat->get_length() ) );
QDomNode noteListNode = doc.createElement( "noteList" );
const Pattern::notes_t* notes = pat->get_notes();
FOREACH_NOTE_CST_IT_BEGIN_END(notes,it) {
Note *pNote = it->second;
assert( pNote );
QDomNode noteNode = doc.createElement( "note" );
writeXmlString( noteNode, "position", QString("%1").arg( pNote->get_position() ) );
writeXmlString( noteNode, "leadlag", QString("%1").arg( pNote->get_lead_lag() ) );
writeXmlString( noteNode, "velocity", QString("%1").arg( pNote->get_velocity() ) );
writeXmlString( noteNode, "pan_L", QString("%1").arg( pNote->get_pan_l() ) );
writeXmlString( noteNode, "pan_R", QString("%1").arg( pNote->get_pan_r() ) );
writeXmlString( noteNode, "pitch", QString("%1").arg( pNote->get_pitch() ) );
writeXmlString( noteNode, "key", pNote->key_to_string() );
writeXmlString( noteNode, "length", QString("%1").arg( pNote->get_length() ) );
writeXmlString( noteNode, "instrument", QString("%1").arg( pNote->get_instrument()->get_id() ) );
noteListNode.appendChild( noteNode );
}