本文整理汇总了C++中TrackList::GetWaveTrackArray方法的典型用法代码示例。如果您正苦于以下问题:C++ TrackList::GetWaveTrackArray方法的具体用法?C++ TrackList::GetWaveTrackArray怎么用?C++ TrackList::GetWaveTrackArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TrackList
的用法示例。
在下文中一共展示了TrackList::GetWaveTrackArray方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetAllPlaybackTracks
TransportTracks GetAllPlaybackTracks(TrackList &trackList, bool selectedOnly, bool useMidi)
{
TransportTracks result;
result.playbackTracks = trackList.GetWaveTrackArray(selectedOnly);
#ifdef EXPERIMENTAL_MIDI_OUT
if (useMidi)
result.midiTracks = trackList.GetNoteTrackConstArray(selectedOnly);
#else
WXUNUSED(useMidi);
#endif
return result;
}
示例2: PlayPlayRegion
//.........这里部分代码省略.........
// valid range maximum of lower bounds
if (t0 < t->GetStartTime())
maxofmins = t->GetStartTime();
else
maxofmins = t0;
// minimum of upper bounds
if (t1 > t->GetEndTime())
minofmaxs = t->GetEndTime();
else
minofmaxs = t1;
// we test if the intersection has no volume
if (minofmaxs <= maxofmins) {
// no volume; play nothing
return;
}
else {
t0 = maxofmins;
t1 = minofmaxs;
}
}
// Can't play before 0...either shifted or latencey corrected tracks
if (t0 < 0.0) {
t0 = 0.0;
}
bool success = false;
if (t1 > t0) {
int token;
if (cutpreview) {
double beforeLen, afterLen;
gPrefs->Read(wxT("/AudioIO/CutPreviewBeforeLen"), &beforeLen, 2.0);
gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0);
double tcp0 = t0-beforeLen;
double tcp1 = (t1+afterLen) - (t1-t0);
SetupCutPreviewTracks(tcp0, t0, t1, tcp1);
if (mCutPreviewTracks)
{
token = gAudioIO->StartStream(
mCutPreviewTracks->GetWaveTrackArray(false),
WaveTrackArray(),
#ifdef EXPERIMENTAL_MIDI_OUT
NoteTrackArray(),
#endif
timetrack, p->GetRate(), tcp0, tcp1, p, false,
t0, t1-t0,
pStartTime);
} else
{
// Cannot create cut preview tracks, clean up and exit
SetPlay(false);
SetStop(false);
SetRecord(false);
return;
}
} else {
if (!timetrack) {
timetrack = t->GetTimeTrack();
}
token = gAudioIO->StartStream(t->GetWaveTrackArray(false),
WaveTrackArray(),
#ifdef EXPERIMENTAL_MIDI_OUT
t->GetNoteTrackArray(false),
#endif
timetrack,
p->GetRate(), t0, t1, p, looped,
0, 0,
pStartTime);
}
if (token != 0) {
success = true;
p->SetAudioIOToken(token);
mBusyProject = p;
#if defined(EXPERIMENTAL_SEEK_BEHIND_CURSOR)
//AC: If init_seek was set, now's the time to make it happen.
gAudioIO->SeekStream(init_seek);
#endif
}
else {
// msmeyer: Show error message if stream could not be opened
wxMessageBox(
#if wxCHECK_VERSION(3,0,0)
_("Error while opening sound device. "
"Please check the playback device settings and the project sample rate."),
#else
_("Error while opening sound device. "
wxT("Please check the playback device settings and the project sample rate.")),
#endif
_("Error"), wxOK | wxICON_EXCLAMATION, this);
}
}
if (!success) {
SetPlay(false);
SetStop(false);
SetRecord(false);
}
}
示例3: OnRecord
void ControlToolBar::OnRecord(wxCommandEvent &evt)
{
if (gAudioIO->IsBusy()) {
mRecord->PopUp();
return;
}
AudacityProject *p = GetActiveProject();
if( evt.GetInt() == 1 ) // used when called by keyboard shortcut. Default (0) ignored.
mRecord->SetShift(true);
if( evt.GetInt() == 2 )
mRecord->SetShift(false);
SetRecord(true, mRecord->WasShiftDown());
if (p) {
TrackList *t = p->GetTracks();
TrackListIterator it(t);
if(it.First() == NULL)
mRecord->SetShift(false);
double t0 = p->GetSel0();
double t1 = p->GetSel1();
if (t1 == t0)
t1 = 1000000000.0; // record for a long, long time (tens of years)
/* TODO: set up stereo tracks if that is how the user has set up
* their preferences, and choose sample format based on prefs */
WaveTrackArray newRecordingTracks, playbackTracks;
#ifdef EXPERIMENTAL_MIDI_OUT
NoteTrackArray midiTracks;
#endif
bool duplex;
gPrefs->Read(wxT("/AudioIO/Duplex"), &duplex, true);
if(duplex){
playbackTracks = t->GetWaveTrackArray(false);
#ifdef EXPERIMENTAL_MIDI_OUT
midiTracks = t->GetNoteTrackArray(false);
#endif
}
else {
playbackTracks = WaveTrackArray();
#ifdef EXPERIMENTAL_MIDI_OUT
midiTracks = NoteTrackArray();
#endif
}
// If SHIFT key was down, the user wants append to tracks
int recordingChannels = 0;
bool shifted = mRecord->WasShiftDown();
if (shifted) {
bool sel = false;
double allt0 = t0;
// Find the maximum end time of selected and all wave tracks
// Find whether any tracks were selected. (If any are selected,
// record only into them; else if tracks exist, record into all.)
for (Track *tt = it.First(); tt; tt = it.Next()) {
if (tt->GetKind() == Track::Wave) {
WaveTrack *wt = static_cast<WaveTrack *>(tt);
if (wt->GetEndTime() > allt0) {
allt0 = wt->GetEndTime();
}
if (tt->GetSelected()) {
sel = true;
if (wt->GetEndTime() > t0) {
t0 = wt->GetEndTime();
}
}
}
}
// Use end time of all wave tracks if none selected
if (!sel) {
t0 = allt0;
}
// Pad selected/all wave tracks to make them all the same length
// Remove recording tracks from the list of tracks for duplex ("overdub")
// playback.
for (Track *tt = it.First(); tt; tt = it.Next()) {
if (tt->GetKind() == Track::Wave && (tt->GetSelected() || !sel)) {
WaveTrack *wt = static_cast<WaveTrack *>(tt);
if (duplex)
playbackTracks.Remove(wt);
t1 = wt->GetEndTime();
if (t1 < t0) {
WaveTrack *newTrack = p->GetTrackFactory()->NewWaveTrack();
newTrack->InsertSilence(0.0, t0 - t1);
newTrack->Flush();
wt->Clear(t1, t0);
bool bResult = wt->Paste(t1, newTrack);
wxASSERT(bResult); // TO DO: Actually handle this.
delete newTrack;
}
newRecordingTracks.Add(wt);
}
}
//.........这里部分代码省略.........
示例4: OnRecord
void ControlToolBar::OnRecord(wxCommandEvent &evt)
{
auto doubleClicked = mRecord->IsDoubleClicked();
mRecord->ClearDoubleClicked();
if (doubleClicked) {
// Display a fixed recording head while scrolling the waves continuously.
// If you overdub, you may want to anticipate some context in existing tracks,
// so center the head. If not, put it rightmost to display as much wave as we can.
const auto project = GetActiveProject();
bool duplex;
gPrefs->Read(wxT("/AudioIO/Duplex"), &duplex, true);
if (duplex) {
// See if there is really anything being overdubbed
if (gAudioIO->GetNumPlaybackChannels() == 0)
// No.
duplex = false;
}
using Mode = AudacityProject::PlaybackScroller::Mode;
project->GetPlaybackScroller().Activate(duplex ? Mode::Centered : Mode::Right);
return;
}
if (gAudioIO->IsBusy()) {
if (!CanStopAudioStream() || 0 == gAudioIO->GetNumCaptureChannels())
mRecord->PopUp();
else
mRecord->PushDown();
return;
}
AudacityProject *p = GetActiveProject();
if( evt.GetInt() == 1 ) // used when called by keyboard shortcut. Default (0) ignored.
mRecord->SetShift(true);
if( evt.GetInt() == 2 )
mRecord->SetShift(false);
SetRecord(true, mRecord->WasShiftDown());
if (p) {
TrackList *trackList = p->GetTracks();
TrackListIterator it(trackList);
if(it.First() == NULL)
mRecord->SetShift(false);
double t0 = p->GetSel0();
double t1 = p->GetSel1();
if (t1 == t0)
t1 = 1000000000.0; // record for a long, long time (tens of years)
/* TODO: set up stereo tracks if that is how the user has set up
* their preferences, and choose sample format based on prefs */
WaveTrackArray newRecordingTracks, playbackTracks;
#ifdef EXPERIMENTAL_MIDI_OUT
NoteTrackArray midiTracks;
#endif
bool duplex;
gPrefs->Read(wxT("/AudioIO/Duplex"), &duplex, true);
if(duplex){
playbackTracks = trackList->GetWaveTrackArray(false);
#ifdef EXPERIMENTAL_MIDI_OUT
midiTracks = trackList->GetNoteTrackArray(false);
#endif
}
else {
playbackTracks = WaveTrackArray();
#ifdef EXPERIMENTAL_MIDI_OUT
midiTracks = NoteTrackArray();
#endif
}
// If SHIFT key was down, the user wants append to tracks
int recordingChannels = 0;
TrackList tracksCopy{};
bool tracksCopied = false;
bool shifted = mRecord->WasShiftDown();
if (shifted) {
bool sel = false;
double allt0 = t0;
// Find the maximum end time of selected and all wave tracks
// Find whether any tracks were selected. (If any are selected,
// record only into them; else if tracks exist, record into all.)
for (Track *tt = it.First(); tt; tt = it.Next()) {
if (tt->GetKind() == Track::Wave) {
WaveTrack *wt = static_cast<WaveTrack *>(tt);
if (wt->GetEndTime() > allt0) {
allt0 = wt->GetEndTime();
}
if (tt->GetSelected()) {
sel = true;
if (wt->GetEndTime() > t0) {
t0 = wt->GetEndTime();
}
}
}
}
//.........这里部分代码省略.........
示例5: PlayPlayRegion
//.........这里部分代码省略.........
else {
init_seek = t0; //AC: init_seek is where playback will 'start'
t0 = t->GetStartTime();
}
#endif
}
t1 = t->GetEndTime();
}
else {
// maybe t1 < t0, with backwards scrubbing for instance
if (backwards)
std::swap(t0, t1);
t0 = std::max(0.0, std::min(t0, latestEnd));
t1 = std::max(0.0, std::min(t1, latestEnd));
if (backwards)
std::swap(t0, t1);
}
int token = -1;
bool success = false;
if (t1 != t0) {
if (cutpreview) {
const double tless = std::min(t0, t1);
const double tgreater = std::max(t0, t1);
double beforeLen, afterLen;
gPrefs->Read(wxT("/AudioIO/CutPreviewBeforeLen"), &beforeLen, 2.0);
gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0);
double tcp0 = tless-beforeLen;
double diff = tgreater - tless;
double tcp1 = (tgreater+afterLen) - diff;
SetupCutPreviewTracks(tcp0, tless, tgreater, tcp1);
if (backwards)
std::swap(tcp0, tcp1);
if (mCutPreviewTracks)
{
AudioIOStartStreamOptions myOptions = options;
myOptions.cutPreviewGapStart = t0;
myOptions.cutPreviewGapLen = t1 - t0;
token = gAudioIO->StartStream(
mCutPreviewTracks->GetWaveTrackArray(false),
WaveTrackArray(),
#ifdef EXPERIMENTAL_MIDI_OUT
NoteTrackArray(),
#endif
tcp0, tcp1, myOptions);
} else
{
// Cannot create cut preview tracks, clean up and exit
SetPlay(false);
SetStop(false);
SetRecord(false);
return -1;
}
} else {
// Lifted the following into AudacityProject::GetDefaultPlayOptions()
/*
if (!timetrack) {
timetrack = t->GetTimeTrack();
}
*/
token = gAudioIO->StartStream(t->GetWaveTrackArray(false),
WaveTrackArray(),
#ifdef EXPERIMENTAL_MIDI_OUT
t->GetNoteTrackArray(false),
#endif
t0, t1, options);
}
if (token != 0) {
success = true;
p->SetAudioIOToken(token);
mBusyProject = p;
#if defined(EXPERIMENTAL_SEEK_BEHIND_CURSOR)
//AC: If init_seek was set, now's the time to make it happen.
gAudioIO->SeekStream(init_seek);
#endif
}
else {
// msmeyer: Show error message if stream could not be opened
wxMessageBox(
_("Error while opening sound device. "
"Please check the playback device settings and the project sample rate."),
_("Error"), wxOK | wxICON_EXCLAMATION, this);
}
}
if (!success) {
SetPlay(false);
SetStop(false);
SetRecord(false);
return -1;
}
// Let other UI update appearance
if (p)
p->GetRulerPanel()->HideQuickPlayIndicator();
return token;
}
示例6: PlayPlayRegion
void ControlToolBar::PlayPlayRegion(double t0, double t1,
bool looped /* = false */)
{
if (gAudioIO->IsBusy()) {
mPlay->PopUp();
#if (AUDACITY_BRANDING == BRAND_THINKLABS)
mLoopPlay->PopUp();
#elif (AUDACITY_BRANDING == BRAND_AUDIOTOUCH)
mPlay->Show();
mPause->Hide();
this->EnablePauseCommand(false);
#endif
return;
}
mStop->Enable();
mRewind->Disable();
mRecord->Disable();
mFF->Disable();
mPause->Enable();
this->EnablePauseCommand(true);
AudacityProject *p = GetActiveProject();
if (p) {
TrackList *t = p->GetTracks();
double maxofmins,minofmaxs;
// JS: clarified how the final play region is computed;
if (t1 == t0) {
// msmeyer: When playing looped, we play the whole file, if
// no range is selected. Otherwise, we play from t0 to end
if (looped) {
// msmeyer: always play from start
t0 = t->GetStartTime();
} else {
// move t0 to valid range
if (t0 < 0)
t0 = t->GetStartTime();
if (t0 > t->GetEndTime())
t0 = t->GetEndTime();
}
// always play to end
t1 = t->GetEndTime();
}
else {
// always t0 < t1 right?
// the set intersection between the play region and the
// valid range maximum of lower bounds
if (t0 < t->GetStartTime())
maxofmins = t->GetStartTime();
else
maxofmins = t0;
// minimum of upper bounds
if (t1 > t->GetEndTime())
minofmaxs = t->GetEndTime();
else
minofmaxs = t1;
// we test if the intersection has no volume
if (minofmaxs <= maxofmins) {
// no volume; play nothing
return;
}
else {
t0 = maxofmins;
t1 = minofmaxs;
}
}
bool success = false;
if (t1 > t0) {
int token =
gAudioIO->StartStream(t->GetWaveTrackArray(false),
WaveTrackArray(), t->GetTimeTrack(),
p->GetRate(), t0, t1, looped);
if (token != 0) {
success = true;
p->SetAudioIOToken(token);
mBusyProject = p;
SetVUMeters(p);
}
else {
// msmeyer: Show error message if stream could not be opened
wxMessageBox(_("Error while opening sound device. Please check the output "
"device settings and the project sample rate."),
_("Error"), wxOK | wxICON_EXCLAMATION, this);
}
}
if (!success) {
SetPlay(false);
SetStop(false);
SetRecord(false);
}
#if (AUDACITY_BRANDING == BRAND_AUDIOTOUCH)
if (success)
//.........这里部分代码省略.........
示例7: OnRecord
void ControlToolBar::OnRecord(wxCommandEvent &evt)
{
if (gAudioIO->IsBusy()) {
#if (AUDACITY_BRANDING == BRAND_AUDIOTOUCH)
if (mIsLocked) // Stop only if in locked mode.
{
this->StopPlaying(); // Stop recording.
mRecord->PopUp();
}
else
{
//v evt.GetClassInfo();
}
#else
mRecord->PopUp();
#endif
return;
}
mPlay->Disable();
#if (AUDACITY_BRANDING == BRAND_THINKLABS)
mLoopPlay->Disable();
#endif
#if (AUDACITY_BRANDING == BRAND_AUDIOTOUCH)
mStop->SetEnabled(mIsLocked);
#else
mStop->Enable();
#endif
mRewind->Disable();
mFF->Disable();
#if (AUDACITY_BRANDING == BRAND_AUDIOTOUCH)
mPause->SetEnabled(mIsLocked);
this->EnablePauseCommand(mIsLocked);
this->SetRecord(mIsLocked); // If locked, push Record down, else up.
#else
mPause->Enable();
mRecord->PushDown();
#endif
AudacityProject *p = GetActiveProject();
if (p) {
TrackList *t = p->GetTracks();
// Don't do this for Audiotouch. Not necessary. The performance hit is in the track being recorded, below.
#if (AUDACITY_BRANDING == BRAND_THINKLABS)
// For versions that default to dual wave/spectrum display,
// switch all tracks to WaveformDisplay on Record, for performance.
TrackListIterator iter(t);
for (Track* pTrack = iter.First(); pTrack; pTrack = iter.Next())
if (pTrack->GetKind() == Track::Wave)
((WaveTrack*)pTrack)->SetDisplay(WaveTrack::WaveformDisplay);
#endif
double t0 = p->GetSel0();
double t1 = p->GetSel1();
if (t1 == t0)
t1 = 1000000000.0; // record for a long, long time (tens of years)
#if (AUDACITY_BRANDING == BRAND_AUDIOTOUCH)
if (p->m_bWantAppendRecording)
{
t0 = t->GetEndTime();
t1 = 1000000000.0; // record for a long, long time (tens of years)
}
gAudioIO->SetWantLatencyCorrection(!p->m_bWantAppendRecording);
#endif
/* TODO: set up stereo tracks if that is how the user has set up
* their preferences, and choose sample format based on prefs */
WaveTrackArray newRecordingTracks, playbackTracks;
bool duplex;
gPrefs->Read("/AudioIO/Duplex", &duplex, true);
int recordingChannels = gPrefs->Read("/AudioIO/RecordChannels", 1);
if( duplex )
playbackTracks = t->GetWaveTrackArray(false);
else
playbackTracks = WaveTrackArray();
for( int c = 0; c < recordingChannels; c++ )
{
WaveTrack *newTrack = p->GetTrackFactory()->NewWaveTrack();
newTrack->SetOffset(t0);
newTrack->SetRate(p->GetRate());
//v for performance newTrack->SetDisplay(WaveTrack::WaveformAndSpectrumDisplay);
newTrack->SetDisplay(WaveTrack::WaveformDisplay);
if( recordingChannels == 2 )
{
if( c == 0 )
{
newTrack->SetChannel(Track::LeftChannel);
newTrack->SetLinked(true);
}
else
newTrack->SetChannel(Track::RightChannel);
}
else
//.........这里部分代码省略.........
示例8: OnRecord
void ControlToolBar::OnRecord(wxCommandEvent &evt)
{
if (gAudioIO->IsBusy()) {
mRecord->PopUp();
return;
}
AudacityProject *p = GetActiveProject();
if (p && p->GetCleanSpeechMode()) {
size_t numProjects = gAudacityProjects.Count();
bool tracks = (p && !p->GetTracks()->IsEmpty());
if (tracks || (numProjects > 1)) {
wxMessageBox(_("Recording in CleanSpeech mode is not possible when a track, or more than one project, is already open."),
_("Recording not permitted"),
wxOK | wxICON_INFORMATION,
this);
mRecord->PopUp();
mRecord->Disable();
return;
}
}
if( evt.GetInt() == 1 ) // used when called by keyboard shortcut. Default (0) ignored.
mRecord->SetShift(true);
if( evt.GetInt() == 2 )
mRecord->SetShift(false);
SetRecord(true);
if (p) {
TrackList *t = p->GetTracks();
TrackListIterator it(t);
if(it.First() == NULL)
mRecord->SetShift(false);
double t0 = p->GetSel0();
double t1 = p->GetSel1();
if (t1 == t0)
t1 = 1000000000.0; // record for a long, long time (tens of years)
/* TODO: set up stereo tracks if that is how the user has set up
* their preferences, and choose sample format based on prefs */
WaveTrackArray newRecordingTracks, playbackTracks;
/* REQUIRES PORTMIDI */
// NoteTrackArray midiTracks;
bool duplex;
gPrefs->Read(wxT("/AudioIO/Duplex"), &duplex, true);
if(duplex){
playbackTracks = t->GetWaveTrackArray(false);
/* REQUIRES PORTMIDI */
// midiTracks = t->GetNoteTrackArray(false);
}
else {
playbackTracks = WaveTrackArray();
/* REQUIRES PORTMIDI */
// midiTracks = NoteTrackArray();
}
// If SHIFT key was down, the user wants append to tracks
int recordingChannels = 0;
bool shifted = mRecord->WasShiftDown();
if (shifted) {
TrackListIterator it(t);
WaveTrack *wt;
bool sel = false;
double allt0 = t0;
// Find the maximum end time of selected and all wave tracks
for (Track *tt = it.First(); tt; tt = it.Next()) {
if (tt->GetKind() == Track::Wave) {
wt = (WaveTrack *)tt;
if (wt->GetEndTime() > allt0) {
allt0 = wt->GetEndTime();
}
if (tt->GetSelected()) {
sel = true;
if (duplex)
playbackTracks.Remove(wt);
if (wt->GetEndTime() > t0) {
t0 = wt->GetEndTime();
}
}
}
}
// Use end time of all wave tracks if none selected
if (!sel) {
t0 = allt0;
}
// Pad selected/all wave tracks to make them all the same length
for (Track *tt = it.First(); tt; tt = it.Next()) {
if (tt->GetKind() == Track::Wave && (tt->GetSelected() || !sel)) {
wt = (WaveTrack *)tt;
t1 = wt->GetEndTime();
if (t1 < t0) {
WaveTrack *newTrack = p->GetTrackFactory()->NewWaveTrack();
newTrack->InsertSilence(0.0, t0 - t1);
newTrack->Flush();
//.........这里部分代码省略.........