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

Method ButtonClicked

Source/SamplePlayer.cpp:521–610  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

519}
520
521void SamplePlayer::ButtonClicked(ClickButton* button, double time)
522{
523 if (button == mPlayButton && mSample != nullptr)
524 {
525 if (mRecord == false)
526 {
527 mCuePointSpeed = 1;
528 mStopOnNoteOff = false;
529 mPlay = true;
530 mAdsr.Clear();
531 mAdsr.Start(time * gInvSampleRateMs, 1);
532 }
533 }
534 if (button == mPauseButton && mSample != nullptr)
535 {
536 mPlay = false;
537 mSwitchAndRamp.StartSwitch();
538 }
539 if (button == mStopButton)
540 {
541 if (mRecord)
542 {
543 StopRecording();
544 }
545 else if (mSample != nullptr)
546 {
547 mPlay = false;
548 mSample->SetPlayPosition(0);
549 mSwitchAndRamp.StartSwitch();
550 }
551 }
552 if (button == mDownloadYoutubeButton)
553 DownloadYoutube("https://www.youtube.com/watch?v=" + mYoutubeId, mYoutubeId);
554 if (button == mLoadFileButton)
555 LoadFile();
556 if (button == mSaveFileButton)
557 SaveFile();
558 if (button == mTrimToZoomButton && mSample != nullptr)
559 {
560 for (auto& cuePoint : mSampleCuePoints)
561 cuePoint.startSeconds = MAX(0, cuePoint.startSeconds - GetZoomStartSeconds());
562
563 Sample* sample = new Sample();
564 sample->Create(GetZoomEndSample() - GetZoomStartSample());
565 sample->Data()->SetNumActiveChannels(mSample->NumChannels());
566 for (int ch = 0; ch < mSample->NumChannels(); ++ch)
567 {
568 float* sampleData = sample->Data()->GetChannel(ch);
569 for (int i = 0; i < sample->LengthInSamples(); ++i)
570 sampleData[i] = mSample->Data()->GetChannel(ch)[i + GetZoomStartSample()];
571 }
572 sample->SetName(mSample->Name());
573 UpdateSample(sample, true);
574 }
575
576 for (size_t i = 0; i < mSearchResultButtons.size(); ++i)
577 {
578 if (button == mSearchResultButtons[i])

Callers

nothing calls this directly

Calls 14

StartSwitchMethod · 0.80
SetPlayPositionMethod · 0.80
SetNumActiveChannelsMethod · 0.80
DataMethod · 0.80
GetChannelMethod · 0.80
LengthInSamplesMethod · 0.80
sizeMethod · 0.80
ClearMethod · 0.45
StartMethod · 0.45
CreateMethod · 0.45
NumChannelsMethod · 0.45
SetNameMethod · 0.45

Tested by

no test coverage detected