MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / ButtonClicked

Method ButtonClicked

Source/MultitrackRecorder.cpp:124–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122}
123
124void MultitrackRecorder::ButtonClicked(ClickButton* button, double time)
125{
126 if (button == mAddTrackButton)
127 {
128 AddTrack();
129 }
130
131 if (button == mBounceButton)
132 {
133 std::string save_prefix = "multitrack_";
134 if (!TheSynth->GetLastSavePath().empty())
135 {
136 // This assumes that mCurrentSaveStatePath always has a valid filename at the end
137 std::string filename = juce::File(TheSynth->GetLastSavePath()).getFileNameWithoutExtension().toStdString();
138 save_prefix = filename + "_";
139 }
140 // Crude way of checking if the filename does not have a date/time in it.
141 if (std::count(save_prefix.begin(), save_prefix.end(), '-') < 3)
142 {
143 save_prefix += "%Y-%m-%d_%H-%M_";
144 }
145 std::string filenamePrefix = ofGetTimestampString(UserPrefs.recordings_path.Get() + save_prefix);
146
147 int numFiles = 0;
148 for (int i = 0; i < (int)mTracks.size(); ++i)
149 {
150 Sample* sample = mTracks[i]->BounceRecording();
151
152 if (sample)
153 {
154 std::string filename = filenamePrefix + ofToString(i + 1) + ".wav";
155 sample->Write(filename.c_str());
156 ++numFiles;
157 }
158 }
159
160 if (numFiles > 0)
161 {
162 mStatusString = "wrote " + ofToString(numFiles) + " files to " + filenamePrefix + "*.wav";
163 mStatusStringTime = gTime;
164 }
165 }
166
167 if (button == mClearButton)
168 {
169 for (auto* track : mTracks)
170 track->Clear();
171 }
172}
173
174void MultitrackRecorder::CheckboxUpdated(Checkbox* checkbox, double time)
175{

Callers

nothing calls this directly

Calls 11

AddTrackFunction · 0.85
ofGetTimestampStringFunction · 0.85
ofToStringFunction · 0.85
emptyMethod · 0.80
GetLastSavePathMethod · 0.80
GetMethod · 0.80
sizeMethod · 0.80
BounceRecordingMethod · 0.80
RemoveTrackMethod · 0.80
WriteMethod · 0.45
ClearMethod · 0.45

Tested by

no test coverage detected