void TrackInfoObject::parse() { // Log parsing of header information in developer mode. This is useful for // tracking down corrupt files. const QString& canonicalLocation = m_fileInfo.canonicalFilePath(); if (CmdlineArgs::Instance().getDeveloper()) { qDebug() << "TrackInfoObject::parse()" << canonicalLocation; } // Parse the information stored in the sound file. SoundSourceProxy proxy(canonicalLocation, m_pSecurityToken); Mixxx::SoundSource* pProxiedSoundSource = proxy.getProxiedSoundSource(); if (pProxiedSoundSource != NULL && proxy.parseHeader() == OK) { // Dump the metadata extracted from the file into the track. // TODO(XXX): This involves locking the mutex for every setXXX // method. We should figure out an optimization where there are private // setters that don't lock the mutex. // If Artist, Title and Type fields are not blank, modify them. // Otherwise, keep their current values. // TODO(rryan): Should we re-visit this decision? if (!(pProxiedSoundSource->getArtist().isEmpty())) { setArtist(pProxiedSoundSource->getArtist()); } if (!(pProxiedSoundSource->getTitle().isEmpty())) { setTitle(pProxiedSoundSource->getTitle()); } if (!(pProxiedSoundSource->getType().isEmpty())) { setType(pProxiedSoundSource->getType()); } setAlbum(pProxiedSoundSource->getAlbum()); setAlbumArtist(pProxiedSoundSource->getAlbumArtist()); setYear(pProxiedSoundSource->getYear()); setGenre(pProxiedSoundSource->getGenre()); setComposer(pProxiedSoundSource->getComposer()); setGrouping(pProxiedSoundSource->getGrouping()); setComment(pProxiedSoundSource->getComment()); setTrackNumber(pProxiedSoundSource->getTrackNumber()); setReplayGain(pProxiedSoundSource->getReplayGain()); setBpm(pProxiedSoundSource->getBPM()); setDuration(pProxiedSoundSource->getDuration()); setBitrate(pProxiedSoundSource->getBitrate()); setSampleRate(pProxiedSoundSource->getSampleRate()); setChannels(pProxiedSoundSource->getChannels()); setKeyText(pProxiedSoundSource->getKey(), mixxx::track::io::key::FILE_METADATA); setHeaderParsed(true); } else { qDebug() << "TrackInfoObject::parse() error at file" << canonicalLocation; setHeaderParsed(false); // Add basic information derived from the filename: parseFilename(); } }
void BeatGrid::scale(enum BPMScale scale) { double bpm = getBpm(); switch (scale) { case DOUBLE: bpm *= 2; break; case HALVE: bpm *= 1.0 / 2; break; case TWOTHIRDS: bpm *= 2.0 / 3; break; case THREEFOURTHS: bpm *= 3.0 / 4; break; case FOURTHIRDS: bpm *= 4.0 / 3; break; case THREEHALVES: bpm *= 3.0 / 2; break; default: DEBUG_ASSERT(!"scale value invalid"); return; } setBpm(bpm); }
void SuperColliderLooper::setup(SuperCollider *sc3) { this->sc3 = sc3; bpm = 120; click = false; soundClick.loadSound("/Users/gene/Audio/Sounds/15__tictacshutup__household-percussion/407__tictacshutup__click-1-off-click.wav"); gui = new ofxUICanvas("Track"); gui->setPosition(5, 5); gui->clearWidgets(); gui->addIntSlider("Bpm", 1, 480, &bpm, 90.0f, 16.0f); gui->setWidgetPosition(OFX_UI_WIDGET_POSITION_RIGHT); gui->addLabelToggle("Click", &click, 60.0f); gui->addLabelToggle("Record", false, 60.0f); vector<string> items; for (int i=0; i<16; i++) items.push_back(ofToString(i+1)); gui->addLabel("Beat:"); guiBeat = gui->addRadio("Beat", items, OFX_UI_ORIENTATION_HORIZONTAL); gui->addLabel("Add:"); gui->addLabelButton("+1", false, 24.0f); gui->addLabelButton("+2", false, 24.0f); gui->addLabelButton("+4", false, 24.0f); gui->addLabelButton("+8", false, 24.0f); gui->addLabelButton("+16", false, 32.0f); gui->autoSizeToFitWidgets(); gui->setWidth(ofGetWidth() - 10); ofAddListener(gui->newGUIEvent, this, &SuperColliderLooper::guiEvent); setBpm(120); clock.start(); ofAddListener(clock.beatEvent, this, &SuperColliderLooper::beatEvent); }
void SuperColliderLooper::guiEvent(ofxUIEventArgs &evt) { if (evt.getName() == "Bpm") { setBpm(bpm); } else if (evt.getName() == "Record") { string filename = ofSystem("Filename"); } else if (evt.getName() == "+1" && ((ofxUILabelButton *) gui->getWidget("+1"))->getValue()) { addNewElement(1, elements.size()); } else if (evt.getName() == "+2" && ((ofxUILabelButton *) gui->getWidget("+2"))->getValue()) { addNewElement(2, elements.size()); } else if (evt.getName() == "+4" && ((ofxUILabelButton *) gui->getWidget("+4"))->getValue()) { addNewElement(4, elements.size()); } else if (evt.getName() == "+8" && ((ofxUILabelButton *) gui->getWidget("+8"))->getValue()) { addNewElement(8, elements.size()); } else if (evt.getName() == "+16" && ((ofxUILabelButton *) gui->getWidget("+16"))->getValue()) { addNewElement(16, elements.size()); } }
void beginUpdate() { m_batchMode = true; foreach( TrackEditorPtr ec, m_editors ) ec->beginUpdate(); } void endUpdate() { foreach( TrackEditorPtr ec, m_editors ) ec->endUpdate(); m_batchMode = false; QTimer::singleShot( 0, m_collection, SLOT(slotUpdated()) ); } void setComment( const QString &newComment ) { FORWARD( setComment( newComment ) ) } void setTrackNumber( int newTrackNumber ) { FORWARD( setTrackNumber( newTrackNumber ) ) } void setDiscNumber( int newDiscNumber ) { FORWARD( setDiscNumber( newDiscNumber ) ) } void setBpm( const qreal newBpm ) { FORWARD( setBpm( newBpm ) ) } void setTitle( const QString &newTitle ) { FORWARD( setTitle( newTitle ) ) } void setArtist( const QString &newArtist ) { FORWARD( setArtist( newArtist ) ) } void setAlbum( const QString &newAlbum ) { FORWARD( setAlbum( newAlbum ) ) } void setAlbumArtist( const QString &newAlbumArtist ) { FORWARD( setAlbumArtist ( newAlbumArtist ) ) } void setGenre( const QString &newGenre ) { FORWARD( setGenre( newGenre ) ) } void setComposer( const QString &newComposer ) { FORWARD( setComposer( newComposer ) ) } void setYear( int newYear ) { FORWARD( setYear( newYear ) ) } private: bool m_batchMode; Collections::AggregateCollection *m_collection; QList<TrackEditorPtr> m_editors; }; #undef FORWARD