Skip to content

Commit

Permalink
save/restore main volume
Browse files Browse the repository at this point in the history
  • Loading branch information
Masaki committed Dec 31, 2023
1 parent 224f3d2 commit 6f8d400
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Source/MelissaDataSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ void MelissaDataSource::loadSettingsFile(const File& file)
{
auto p = settings["previous"].getDynamicObject();
if (p->hasProperty("file")) previous_.filePath_ = p->getProperty("file");
if (p->hasProperty("main_volume")) previous_.mainVolume_ = p->getProperty("main_volume");
if (p->hasProperty("pitch")) previous_.pitch_ = p->getProperty("pitch");

if (p->hasProperty("a")) previous_.aRatio_ = p->getProperty("a");
Expand Down Expand Up @@ -296,6 +297,7 @@ void MelissaDataSource::saveSettingsFile()

auto previous = new DynamicObject();
previous->setProperty("file", currentSongFilePath_);
previous->setProperty("main_volume", model_->getMainVolume());
previous->setProperty("pitch", model_->getPitch());
previous->setProperty("a", model_->getLoopAPosRatio());
previous->setProperty("b", model_->getLoopBPosRatio());
Expand Down Expand Up @@ -707,6 +709,7 @@ void MelissaDataSource::restorePreviousState()
#endif

loadFileAsync(file, [&]() {
model_->setMainVolume(previous_.mainVolume_);
model_->setPitch(previous_.pitch_);
model_->setLoopPosRatio(previous_.aRatio_, previous_.bRatio_);
model_->setOutputMode(previous_.outputMode_);
Expand Down
4 changes: 3 additions & 1 deletion Source/MelissaDataSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class MelissaDataSource : public juce::AsyncUpdater
struct Previous
{
juce::String filePath_;

float mainVolume_;
float pitch_;

float aRatio_;
Expand Down Expand Up @@ -117,7 +119,7 @@ class MelissaDataSource : public juce::AsyncUpdater
UIState uiState_;

Previous() :
filePath_(""), pitch_(0.f),
filePath_(""), mainVolume_(1.f), pitch_(0.f),
aRatio_(0.f), bRatio_(1.f),
outputMode_(kOutputMode_LR), musicVolume_(1.f), metronomeVolume_(1.f), volumeBalance_(0.5f),
/* metronomeSw_(false), */ bpm_(kBpmShouldMeasure), accent_(4), beatPositionMSec_(0.f),
Expand Down

0 comments on commit 6f8d400

Please sign in to comment.