void TranscriptionToolBar::OnStartOff(wxCommandEvent & WXUNUSED(event)) { //If IO is busy, abort immediately if (gAudioIO->IsBusy()){ SetButton(false,mButtons[TTB_StartOff]); return; } mVk->AdjustThreshold(GetSensitivity()); AudacityProject *p = GetActiveProject(); TrackList *tl = p->GetTracks(); TrackListOfKindIterator iter(Track::Wave, tl); SetButton(false, mButtons[TTB_StartOff]); Track *t = iter.First(); //Make a track if(t) { sampleCount start,len; GetSamples((WaveTrack*)t, &start,&len); //Adjust length to end if selection is null //if(len == 0) //len = (WaveTrack*)t->GetSequence()->GetNumSamples()-start; sampleCount newstart = mVk->OffForward(*(WaveTrack*)t,start,len); double newpos = newstart / ((WaveTrack*)t)->GetRate(); p->SetSel0(newpos); p->RedrawProject(); SetButton(false, mButtons[TTB_StartOn]); } }
void TranscriptionToolBar::OnSelectSound(wxCommandEvent & WXUNUSED(event)) { //If IO is busy, abort immediately if (gAudioIO->IsBusy()){ SetButton(false,mButtons[TTB_SelectSound]); return; } mVk->AdjustThreshold(GetSensitivity()); AudacityProject *p = GetActiveProject(); TrackList *tl = p->GetTracks(); TrackListOfKindIterator iter(Track::Wave, tl); Track *t = iter.First(); //Make a track if(t) { auto wt = static_cast<const WaveTrack*>(t); sampleCount start, len; GetSamples(wt, &start, &len); //Adjust length to end if selection is null //if(len == 0) //len = wt->GetSequence()->GetNumSamples()-start; double rate = wt->GetRate(); auto newstart = mVk->OffBackward(*wt, start, start); auto newend = mVk->OffForward(*wt, start + len, (int)(tl->GetEndTime() * rate)); //reset the selection bounds. p->SetSel0(newstart.as_double() / rate); p->SetSel1(newend.as_double() / rate); p->RedrawProject(); } SetButton(false,mButtons[TTB_SelectSound]); }
void HighlightTextCtrl::OnMouseEvent(wxMouseEvent& event) { if (event.ButtonUp()) { long from, to; this->GetSelection(&from, &to); int nCurSyl = mLyrics->GetCurrentSyllableIndex(); int nNewSyl = mLyrics->FindSyllable(from); if (nNewSyl != nCurSyl) { Syllable* pCurSyl = mLyrics->GetSyllable(nNewSyl); AudacityProject* pProj = GetActiveProject(); pProj->SetSel0(pCurSyl->t); //v Should probably select to end as in AudacityProject::OnSelectCursorEnd, // but better to generalize that in AudacityProject methods. pProj->mViewInfo.selectedRegion.setT1(pCurSyl->t); } } event.Skip(); }
void TranscriptionToolBar::OnSelectSilence(wxCommandEvent & WXUNUSED(event)) { //If IO is busy, abort immediately if (gAudioIO->IsBusy()){ SetButton(false,mButtons[TTB_SelectSilence]); return; } mVk->AdjustThreshold(GetSensitivity()); AudacityProject *p = GetActiveProject(); TrackList *tl = p->GetTracks(); if(auto wt = *tl->Any<const WaveTrack>().begin()) { sampleCount start, len; GetSamples(wt, &start, &len); //Adjust length to end if selection is null //if(len == 0) //len = wt->GetSequence()->GetNumSamples()-start; double rate = wt->GetRate(); auto newstart = mVk->OnBackward(*wt, start, start); auto newend = mVk->OnForward(*wt, start + len, (int)(tl->GetEndTime() * rate)); //reset the selection bounds. p->SetSel0(newstart.as_double() / rate); p->SetSel1(newend.as_double() / rate); p->RedrawProject(); } SetButton(false,mButtons[TTB_SelectSilence]); }