void TranscriptionToolBar::OnEndOff(wxCommandEvent & WXUNUSED(event)) { //If IO is busy, abort immediately if (gAudioIO->IsBusy()){ SetButton(false,mButtons[TTB_EndOff]); 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) { sampleCount start,len; GetSamples((WaveTrack*)t, &start,&len); //Adjust length to end if selection is null if(len == 0) { len = start; start = 0; } sampleCount newEnd = mVk->OffBackward(*(WaveTrack*)t,start+ len,len); double newpos = newEnd / ((WaveTrack*)t)->GetRate(); p->SetSel1(newpos); p->RedrawProject(); SetButton(false, mButtons[TTB_EndOff]); } }
void TranscriptionToolBar::OnEndOff(wxCommandEvent & WXUNUSED(event)) { //If IO is busy, abort immediately if (gAudioIO->IsBusy()){ SetButton(false,mButtons[TTB_EndOff]); return; } mVk->AdjustThreshold(GetSensitivity()); AudacityProject *p = GetActiveProject(); auto t = *p->GetTracks()->Any< const WaveTrack >().begin(); 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 = start; start = 0; } auto newEnd = mVk->OffBackward(*wt, start + len, len); double newpos = newEnd.as_double() / wt->GetRate(); p->SetSel1(newpos); p->RedrawProject(); SetButton(false, mButtons[TTB_EndOff]); } }
void Coil::GridMap () { double position[3] = {0.0,0.0,0.0}; double max = 0.0; for (int k=0; k< (m_dim==3?m_points:1); k++) { position [ZC] = (m_dim==3?k*m_extent/m_points-m_extent/2:0.0); for (int j=0; j<m_points; j++) { position [YC] = j*m_extent/m_points-m_extent/2; for (int i=0; i<m_points; i++) { position [XC] = i*m_extent/m_points-m_extent/2; double mag = m_scale*GetSensitivity(position); m_sensmag(i,j,k) = mag; max = (max>mag?max:mag); m_senspha(i,j,k) = ( (m_conjugate?-1.0:1.0) * ( GetPhase(position) + m_phase) ); if (m_senspha(i,j,k) != 0.0) m_complex = true; } } } m_norm = 1/max; }
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(); SetButton(false, mButtons[TTB_StartOff]); auto t = *p->GetTracks()->Any< const WaveTrack >().begin(); 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; auto newstart = mVk->OffForward(*wt, start, len); double newpos = newstart.as_double() / wt->GetRate(); auto &selectedRegion = p->GetViewInfo().selectedRegion; selectedRegion.setT0( newpos ); p->RedrawProject(); SetButton(false, mButtons[TTB_StartOn]); } }
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) { 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; auto newstart = mVk->OffForward(*wt, start, len); double newpos = newstart.as_double() / wt->GetRate(); p->SetSel0(newpos); p->RedrawProject(); SetButton(false, mButtons[TTB_StartOn]); } }
double Coil::GetSensitivity (const double time) { double position[3]; position[0]=World::instance()->Values[XC]; position[1]=World::instance()->Values[YC]; position[2]=World::instance()->Values[ZC]; DynamicVariables* dv = DynamicVariables::instance(); dv->m_Motion->GetValue(time,position); if (m_interpolate) { return m_norm*InterpolateSensitivity(position); } else { return m_norm*GetSensitivity(position); } }
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(); TrackListIterator iter(tl); 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; double rate = ((WaveTrack*)t)->GetRate(); sampleCount newstart = mVk->OffBackward(*(WaveTrack*)t,start,start); sampleCount newend = mVk->OffForward(*(WaveTrack*)t,start+len,(int)(tl->GetEndTime()*rate)); //reset the selection bounds. p->SetSel0(newstart / rate); p->SetSel1(newend / rate); p->RedrawProject(); } SetButton(false,mButtons[TTB_SelectSound]); }
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(); 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->OffBackward(*wt, start, start); auto newend = mVk->OffForward(*wt, start + len, (int)(tl->GetEndTime() * rate)); //reset the selection bounds. auto &selectedRegion = p->GetViewInfo().selectedRegion; selectedRegion.setTimes( newstart.as_double() / rate, newend.as_double() / rate ); p->RedrawProject(); } SetButton(false,mButtons[TTB_SelectSound]); }
void Coil::Receive (long lADC) { m_signal->Repo()->TP(lADC) = World::instance()->time; double sens = GetSensitivity (m_signal->Repo()->TP(lADC)); double phase = GetPhase (m_signal->Repo()->TP(lADC)); long pos = m_signal->Repo()->Position(lADC); double tm = 0.0; for (int i = 0; i < m_signal->Repo()->Compartments(); i++) { tm = - World::instance()->phase + phase + World::instance()->solution[PHASE+ i*3]; m_signal->Repo()->at(pos + i*3) += sens * World::instance()->solution[i*3 + AMPL] * cos (tm); m_signal->Repo()->at(pos + 1 + i*3) += sens * World::instance()->solution[i*3 + AMPL] * sin (tm); m_signal->Repo()->at(pos + 2 + i*3) += sens * World::instance()->solution[i*3 + 2]; } }
void TranscriptionToolBar::OnAutomateSelection(wxCommandEvent & WXUNUSED(event)) { //If IO is busy, abort immediately if (gAudioIO->IsBusy()) { SetButton(false,mButtons[TTB_EndOff]); return; } wxBusyCursor busy; mVk->AdjustThreshold(GetSensitivity()); AudacityProject *p = GetActiveProject(); TrackList *tl = p->GetTracks(); TrackListIterator iter(tl); 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 = start; start = 0; } int lastlen = 0; sampleCount newStart, newEnd; double newStartPos, newEndPos; //This is the minumum word size in samples (.05 is 50 ms) int minWordSize = (int)(((WaveTrack*)t)->GetRate() * .05); //Continue until we have processed the entire //region, or we are making no progress. while(len > 0 && lastlen != len) { lastlen = len; newStart = mVk->OnForward(*(WaveTrack*)t,start,len); //JKC: If no start found then don't add any labels. if( newStart==start) break; //Adjust len by the NEW start position len -= (newStart - start); //Adjust len by the minimum word size len -= minWordSize; //OK, now we have found a NEW starting point. A 'word' should be at least //50 ms long, so jump ahead minWordSize newEnd = mVk->OffForward(*(WaveTrack*)t,newStart+minWordSize, len); //If newEnd didn't move, we should give up, because // there isn't another end before the end of the selection. if(newEnd == (newStart + minWordSize)) break; //Adjust len by the NEW word end len -= (newEnd - newStart); //Calculate the start and end of the words, in seconds newStartPos = newStart / ((WaveTrack*)t)->GetRate(); newEndPos = newEnd / ((WaveTrack*)t)->GetRate(); //Increment start = newEnd; p->DoAddLabel(SelectedRegion(newStartPos, newEndPos)); p->RedrawProject(); } SetButton(false, mButtons[TTB_AutomateSelection]); } }