CObjectMetaEventTempo::CObjectMetaEventTempo(): tempo(120) { dataLen = 3; pData = new BYTE[3]; SetTempo(120); }
int OPLMIDIDevice::PlayTick() { DWORD delay = 0; while (delay == 0 && Events != NULL) { DWORD *event = (DWORD *)(Events->lpData + Position); if (MEVT_EVENTTYPE(event[2]) == MEVT_TEMPO) { SetTempo(MEVT_EVENTPARM(event[2])); } else if (MEVT_EVENTTYPE(event[2]) == MEVT_LONGMSG) { // Should I handle master volume changes? } else if (MEVT_EVENTTYPE(event[2]) == 0) { // Short MIDI event int status = event[2] & 0xff; int parm1 = (event[2] >> 8) & 0x7f; int parm2 = (event[2] >> 16) & 0x7f; HandleEvent(status, parm1, parm2); } // Advance to next event. if (event[2] < 0x80000000) { // Short message Position += 12; } else { // Long message Position += 12 + ((MEVT_EVENTPARM(event[2]) + 3) & ~3); } // Did we use up this buffer? if (Position >= Events->dwBytesRecorded) { Events = Events->lpNext; Position = 0; if (Callback != NULL) { Callback(MOM_DONE, CallbackData, 0, 0); } } if (Events == NULL) { // No more events. Just return something to keep the song playing // while we wait for more to be submitted. return int(Division); } delay = *(DWORD *)(Events->lpData + Position); }
void BassSoundEngine::Update(float dwTimeMilliSecond) { if(ScreenState==SCREEN_GAMEMAIN) { if(BASS_ChannelIsActive(channel[0])!=BASS_ACTIVE_PLAYING || !channel[0]){ if(m_pAudio) // audio stopped, resume audio in video m_pAudio->put_Volume(Lin2dB(defaultVolume)); }else{ // channel 0 is active if(m_pAudio) m_pAudio->put_Volume(-10000); if(pitch_factor!=0) SetPitch(pitch_factor,0,true), pitch_factor = 0; if(sampleRate_factor!=0) SetSampleRate(sampleRate_factor,0,true), sampleRate_factor = 0; if(tempo_factor!=0) SetTempo(tempo_factor,0,true), tempo_factor = 0; } } for(int i = 0; i < nowChannel; i++) { if(channel[i]!=NULL) { float volume; BASS_ChannelGetAttribute(channel[i], BASS_ATTRIB_VOL, &volume); if(volume==0){ BASS_ChannelStop(channel[i]); channel[i] = NULL; } if(volume>volumeDes[i]) { volume -= soundSpd*dwTimeMilliSecond; if(volume<volumeDes[i]) volume = volumeDes[i]; } if(volume<volumeDes[i]) { volume += soundSpd*dwTimeMilliSecond; if(volume>volumeDes[i]) volume = volumeDes[i]; } BASS_ChannelSetAttribute(channel[i], BASS_ATTRIB_VOL, volume); if(volume==0) FreeChannel(i, true); } } }
void FmodSoundEngine::Update(float dwTimeMilliSecond) { FMOD::Channel **channel = (FMOD::Channel**)this->channel; if(ScreenState==SCREEN_GAMEMAIN){ bool status = false; channel[0]->isPlaying(&status); if(!status || !channel[0]){ // audio stopped, resume audio in video if(m_pAudio) m_pAudio->put_Volume(Lin2dB(defaultVolume)); }else{ // channel 0 is active if(m_pAudio) m_pAudio->put_Volume(-10000); if(pitch_factor!=0) SetPitch(pitch_factor,0,true), pitch_factor = 0; if(sampleRate_factor!=0) SetSampleRate(sampleRate_factor,0,true), sampleRate_factor = 0; if(tempo_factor!=0) SetTempo(tempo_factor,0,true), tempo_factor = 0; } } system->update(); for(int i = 0; i < nowChannel; i++) { if(channel[i]!=NULL) { float volume; result = channel[i]->getVolume(&volume); if(volume>volumeDes[i]) { volume -= soundSpd*dwTimeMilliSecond; if(volume<volumeDes[i]) volume = volumeDes[i]; } else if(volume<volumeDes[i]) { volume += soundSpd*dwTimeMilliSecond; if(volume>volumeDes[i]) volume = volumeDes[i]; } channel[i]->setVolume(volume); if(volume==0) FreeChannel(i, true); } } }
int addBPM(int bpm, int line,int counter,int dividor, int blocknum) { struct WBlocks *wblock=getWBlockFromNum(-1,blocknum); if(wblock==NULL) { RError("unknown block(%p)",blocknum); return -1; } Place *place = PlaceCreate(line,counter,dividor); struct Tempos *tempo = SetTempo(wblock->block,place,bpm); wblock->block->is_dirty = true; return ListFindElementPos3(&wblock->block->tempos->l,&tempo->l); }
int addBPM(int bpm, Place place, int blocknum) { struct Tracker_Windows *window; struct WBlocks *wblock=getWBlockFromNumA(-1,&window,blocknum); if(wblock==NULL) return -1; if (!PlaceLegal(wblock->block, &place)) { GFX_Message(NULL, "Place %s is not legal", PlaceToString(&place)); return -1; } ADD_UNDO(Tempos_CurrPos(window)); struct Tempos *tempo = SetTempo(wblock->block,&place,bpm); window->must_redraw=true; return ListFindElementPos3(&wblock->block->tempos->l,&tempo->l); }
AnimationFrame::AnimationFrame(std::function<void ()> onClose, wxDocument *doc, wxView *view, wxFrame *parent, const wxSize& size) : #if defined(BUILD_FOR_VIEWER) && (BUILD_FOR_VIEWER != 0) wxDocChildFrame(doc, view, parent, wxID_ANY, wxT("CalChart Viewer"), wxDefaultPosition, size), #else wxFrame(parent, wxID_ANY, wxT("CalChart Viewer"), wxDefaultPosition, size), #endif mCanvas(NULL), mOmniViewCanvas(NULL), mTimer(new wxTimer(this, CALCHART__anim_next_beat_timer)), mTempo(120), mTimerOn(false), mWhenClosed(onClose) { // Give it an icon // give this a view so it can pick up document changes mAnimationView = new AnimationView(); mAnimationView->SetDocument(doc); mAnimationView->SetFrame(this); SetBandIcon(this); // this frame has 2 status bars at the bottom CreateStatusBar(2); // Make a menubar wxMenu *anim_menu = new wxMenu; anim_menu->Append(CALCHART__anim_reanimate, wxT("&Reanimate Show...\tCTRL-RETURN"), wxT("Regenerate animation")); anim_menu->Append(CALCHART__anim_select_coll, wxT("&Select Collisions"), wxT("Select colliding points")); anim_menu->Append(wxID_CLOSE, wxT("&Close Window\tCTRL-W"), wxT("Close window")); wxMenuBar *menu_bar = new wxMenuBar; menu_bar->Append(anim_menu, wxT("&Animate")); wxMenu *omni_menu = new wxMenu; omni_menu->Append(CALCHART__FollowMarcher, wxT("&Follow Marcher"), wxT("Follow Marcher")); omni_menu->Append(CALCHART__ToggleCrowd, wxT("&Toggle Crowd"), wxT("Toggle Crowd")); omni_menu->Append(CALCHART__ToggleMarching, wxT("&Toggle Marching"), wxT("Toggle Marching")); omni_menu->Append(CALCHART__ToggleShowOnlySelected, wxT("&Toggle Show Selected"), wxT("Toggle Show Selected")); omni_menu->Append(CALCHART__ShowKeyboardControls, wxT("&Show Controls"), wxT("Show keyboard controls")); menu_bar->Append(omni_menu, wxT("&OmniView")); wxMenu *split_menu = new wxMenu; split_menu->Append(CALCHART__SplitViewHorizontal, wxT("Split &Horizontally\tCtrl-H"), wxT("Split Horizontally")); split_menu->Append(CALCHART__SplitViewVertical, wxT("Split &Vertically\tCtrl-V"), wxT("Split Vertically")); split_menu->Append(CALCHART__SplitViewUnsplit, wxT("&Unsplit\tCtrl-U"), wxT("Unsplit")); split_menu->Append(CALCHART__SplitViewSwapAnimateAndOmni, wxT("&Swap Views\tCtrl-S"), wxT("Swap Views")); menu_bar->Append(split_menu, wxT("&Split")); SetMenuBar(menu_bar); // Add a toolbar // Add the field canvas here so that it gets the focus when we switch to frame. mSplitter = new wxSplitterWindow(this, wxID_ANY); mSplitter->SetSize(GetClientSize()); mSplitter->SetSashGravity(0.5); mSplitter->SetMinimumPaneSize(20); mSplitter->SetWindowStyleFlag(mSplitter->GetWindowStyleFlag() | wxSP_LIVE_UPDATE); mSplitter->SetMinSize(wxSize(300, 400)); mOmniViewCanvas = new CCOmniView_Canvas(mAnimationView, mSplitter); mCanvas = new AnimationCanvas(mAnimationView, mSplitter); mSplitA = mOmniViewCanvas; mSplitB = mCanvas; if (!GetConfiguration_AnimationFrameOmniAnimation()) { std::swap(mSplitA, mSplitB); } mSplitter->Initialize(mSplitA); if (GetConfiguration_AnimationFrameSplitScreen()) { if (GetConfiguration_AnimationFrameSplitVertical()) { mSplitter->SplitVertically(mSplitA, mSplitB); } else { mSplitter->SplitHorizontally(mSplitA, mSplitB); } } mSplitter->SetSashPosition(GetConfiguration_AnimationFrameSashPosition()); AddCoolToolBar(GetAnimationToolBar(), *this); // set up the frame this->SetSizeHints(wxDefaultSize, wxDefaultSize); this->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_MENU)); wxBoxSizer *topsizer = new wxBoxSizer(wxVERTICAL); wxBoxSizer *toprow = new wxBoxSizer(wxHORIZONTAL); wxSizerFlags topRowSizerFlags = wxSizerFlags(0).Expand().Border(0, 5); wxSizerFlags centerText = wxSizerFlags(0).Border(wxALL, 5).Align(wxALIGN_CENTER_HORIZONTAL); wxSizerFlags centerWidget = wxSizerFlags(0).Expand().Border(wxALL, 5).Align(wxALIGN_CENTER_HORIZONTAL); // Add the controls wxBoxSizer *sizer1 = new wxBoxSizer(wxVERTICAL); sizer1->Add(new wxStaticText(this, wxID_ANY, wxT("Collisions")), centerText); static const wxString collis_text[] = { wxT("Ignore"), wxT("Show"), wxT("Beep") }; wxChoice *collis = new wxChoice(this, CALCHART__anim_collisions, wxDefaultPosition, wxDefaultSize, sizeof(collis_text)/sizeof(const wxString), collis_text); collis->SetSelection(mAnimationView->GetCollisionType()); sizer1->Add(collis, centerWidget); toprow->Add(sizer1, topRowSizerFlags); sizer1 = new wxBoxSizer(wxVERTICAL); sizer1->Add(new wxStaticText(this, wxID_ANY, wxT("Tempo")), centerText); // defect 3538572: Callings set may update tempo, cache value before call. unsigned tmp = GetTempo(); wxSpinCtrl *tempo = new wxSpinCtrl(this, CALCHART__anim_tempo); tempo->SetRange(10, 300); tempo->SetValue(tmp); SetTempo(tmp); sizer1->Add(tempo, centerWidget); toprow->Add(sizer1, topRowSizerFlags); // Sheet slider (will get set later with UpdatePanel()) sizer1 = new wxBoxSizer(wxVERTICAL); sizer1->Add(new wxStaticText(this, wxID_ANY, wxT("Sheet")), centerText); mSheetSlider = new wxSlider(this, CALCHART__anim_gotosheet, 1, 1, 2, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS); sizer1->Add(mSheetSlider, centerWidget); toprow->Add(sizer1, topRowSizerFlags); // Beat slider (will get set later with UpdatePanel()) sizer1 = new wxBoxSizer(wxVERTICAL); sizer1->Add(new wxStaticText(this, wxID_ANY, wxT("Beat")), centerText); mBeatSlider = new wxSlider(this, CALCHART__anim_gotobeat, 0, 0, 1, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS); sizer1->Add(mBeatSlider, centerWidget); toprow->Add(sizer1, topRowSizerFlags); sizer1 = new wxBoxSizer(wxVERTICAL); mErrorList = new wxChoice(this, CALCHART__anim_errors, wxDefaultPosition, wxDefaultSize, 0, NULL); mErrorList->Append(wxT("Errors...")); mErrorList->SetSelection(0); sizer1->Add(mErrorList, centerWidget); mErrorText = new FancyTextWin(this, wxID_ANY); sizer1->Add(mErrorText, wxSizerFlags(1).Expand().Border(wxALL, 5).Align(wxALIGN_CENTER_HORIZONTAL)); toprow->Add(sizer1, topRowSizerFlags); topsizer->Add(toprow, wxSizerFlags(0).Border(0, 5)); // Add the field canvas topsizer->Add(mSplitter, wxSizerFlags(1).Expand()); SetSizer( topsizer ); topsizer->SetSizeHints(this); // set size hints to honour minimum size this->Layout(); mAnimationView->Generate(); UpdatePanel(); Fit(); SetSize(size); Show(true); // make animation screen large by default. // Maximize(true); }
void AnimationFrame::OnSlider_anim_tempo(wxSpinEvent& event) { SetTempo(event.GetPosition()); StartTimer(); }
int SoftSynthMIDIDevice::PlayTick() { uint32_t delay = 0; while (delay == 0 && Events != NULL) { uint32_t *event = (uint32_t *)(Events->lpData + Position); if (MEVENT_EVENTTYPE(event[2]) == MEVENT_TEMPO) { SetTempo(MEVENT_EVENTPARM(event[2])); } else if (MEVENT_EVENTTYPE(event[2]) == MEVENT_LONGMSG) { HandleLongEvent((uint8_t *)&event[3], MEVENT_EVENTPARM(event[2])); } else if (MEVENT_EVENTTYPE(event[2]) == 0) { // Short MIDI event int status = event[2] & 0xff; int parm1 = (event[2] >> 8) & 0x7f; int parm2 = (event[2] >> 16) & 0x7f; HandleEvent(status, parm1, parm2); if (synth_watch) { static const char *const commands[8] = { "Note off", "Note on", "Poly press", "Ctrl change", "Prgm change", "Chan press", "Pitch bend", "SysEx" }; char buffer[128]; mysnprintf(buffer, countof(buffer), "C%02d: %11s %3d %3d\n", (status & 15) + 1, commands[(status >> 4) & 7], parm1, parm2); #ifdef _WIN32 I_DebugPrint(buffer); #else fputs(buffer, stderr); #endif } } // Advance to next event. if (event[2] < 0x80000000) { // Short message Position += 12; } else { // Long message Position += 12 + ((MEVENT_EVENTPARM(event[2]) + 3) & ~3); } // Did we use up this buffer? if (Position >= Events->dwBytesRecorded) { Events = Events->lpNext; Position = 0; if (Callback != NULL) { Callback(CallbackData); } } if (Events == NULL) { // No more events. Just return something to keep the song playing // while we wait for more to be submitted. return int(Division); } delay = *(uint32_t *)(Events->lpData + Position); }