Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
essej committed Jan 15, 2022
2 parents 07dcd46 + 17bcc2e commit 872f911
Show file tree
Hide file tree
Showing 10 changed files with 140 additions and 27 deletions.
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ endif()
# `project()` command. `project()` sets up some helpful variables that describe source/binary
# directories, and the current project version. This is a standard CMake command.

project(SonoBus VERSION 1.4.8)
project(SonoBus VERSION 1.4.9)

set(BUILDVERSION 71)
set(BUILDVERSION 72)


# If you've installed JUCE somehow (via a package manager, or directly using the CMake install
Expand Down Expand Up @@ -226,6 +226,8 @@ function(sono_add_custom_plugin_target target_name product_name formats is_instr
else()
# Linux
list (APPEND PlatSourceFiles Source/CrossPlatformUtilsLinux.cpp)
list ( APPEND PLAT_COMPILE_DEFS
JUCE_USE_MP3AUDIOFORMAT=1 )
endif()


Expand Down Expand Up @@ -411,7 +413,7 @@ function(sono_add_custom_plugin_target target_name product_name formats is_instr
JUCE_VST3_CAN_REPLACE_VST2=0
JUCE_DISPLAY_SPLASH_SCREEN=0
JUCE_USE_CUSTOM_PLUGIN_STANDALONE_APP=1
JUCE_USE_MP3AUDIOFORMAT=1
JUCE_USE_WINDOWS_MEDIA_FORMAT=1
JUCE_LOAD_CURL_SYMBOLS_LAZILY=1
JUCE_ASIO=1
JUCE_WASAPI=1
Expand Down
16 changes: 7 additions & 9 deletions Source/Metronome.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ void Metronome::processMix (int nframes, float * inOutDataL, float * inOutDataR,

tempBuffer.clear(0, nframes);

//long iTimestamp = (long) lrint(timestamp);
int frames = nframes;

double beatInt;
Expand All @@ -70,12 +69,10 @@ void Metronome::processMix (int nframes, float * inOutDataL, float * inOutDataR,
framesUntilBeat = (long) lrint(mCurrentBeatRemainRatio * framesInBeat);
}
else {
//framesUntilBeat = (framesInBeat - (iTimestamp % framesInBeat)) % framesInBeat;
//framesUntilBar = (framesInBar - (iTimestamp % framesInBar)) % framesInBar;
framesUntilBar = (long) lrint(fmod(1.0 - barFrac, 1.0) * framesInBar);;
framesUntilBeat = (long) lrint(fmod(1.0 - beatFrac, 1.0) * framesInBeat);

framesUntilBar = (long) lrint((1.0 - barFrac) * framesInBar);;
framesUntilBeat = (long) lrint((1.0 - beatFrac) * framesInBeat);

//DBG("Beattime: " << beatTime << " framesuntilbeat: " << framesUntilBeat << " beatfrac: " << beatFrac);
mCurrBeatPos = beatTime;
}

Expand Down Expand Up @@ -173,11 +170,12 @@ void Metronome::processMix (int nframes, float * inOutDataL, float * inOutDataR,
}
}

void Metronome::resetRelativeStart()
void Metronome::resetRelativeStart(double startBeatPos)
{
mCurrBeatPos = startBeatPos;
mCurrentBarRemainRatio = 0.0;
mCurrentBeatRemainRatio = 0.0;
mCurrBeatPos = 0.0;
mCurrentBeatRemainRatio = fmod(1.0 - fmod(mCurrBeatPos, 1.0), 1.0);
mCurrentBarRemainRatio = fmod(1.0 - fmod(mCurrBeatPos / mBeatsPerBar, 1.0), 1.0);
}

void Metronome::setRemainRatios(double barRemain, double beatRemain)
Expand Down
2 changes: 1 addition & 1 deletion Source/Metronome.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace SonoAudio
int getBeatsPerBar() const { return mBeatsPerBar; }


void resetRelativeStart();
void resetRelativeStart(double startBeatPos = 0.0);
void setRemainRatios(double barRemain, double beatRemain);

double getCurrBeatPos() const { return mCurrBeatPos; }
Expand Down
30 changes: 24 additions & 6 deletions Source/SonobusPluginEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,15 @@ SonobusAudioProcessorEditor::SonobusAudioProcessorEditor (SonobusAudioProcessor&
mMetSyncButton->setColour(TextButton::textColourOnId, Colours::darkblue);
mMetSyncButton->setTooltip(TRANS("Synchronize metronome tempo with plugin host"));

mMetSyncFileButton = std::make_unique<TextButton>("metsync");
mMetSyncFileButton->setButtonText(TRANS("Sync with File"));
mMetSyncFileButton->setLookAndFeel(&smallLNF);
mMetSyncFileButton->setClickingTogglesState(true);
//mMetSyncButton->addListener(this);
mMetSyncFileButton->setColour(TextButton::buttonOnColourId, Colour::fromFloatRGBA(0.6, 1.0, 0.6, 0.7f));
mMetSyncFileButton->setColour(TextButton::textColourOnId, Colours::darkblue);
mMetSyncFileButton->setTooltip(TRANS("Synchronize metronome start with file playback"));


mDrySlider = std::make_unique<Slider>(Slider::LinearHorizontal, Slider::TextBoxAbove);
mDrySlider->setName("dry");
Expand Down Expand Up @@ -667,6 +676,7 @@ SonobusAudioProcessorEditor::SonobusAudioProcessorEditor (SonobusAudioProcessor&
mMetTempoAttachment = std::make_unique<AudioProcessorValueTreeState::SliderAttachment> (p.getValueTreeState(), SonobusAudioProcessor::paramMetTempo, *mMetTempoSlider);
mMetSendAttachment = std::make_unique<AudioProcessorValueTreeState::ButtonAttachment> (p.getValueTreeState(), SonobusAudioProcessor::paramSendMetAudio, *mMetSendButton);
mMetSyncAttachment = std::make_unique<AudioProcessorValueTreeState::ButtonAttachment> (p.getValueTreeState(), SonobusAudioProcessor::paramSyncMetToHost, *mMetSyncButton);
mMetSyncFileAttachment = std::make_unique<AudioProcessorValueTreeState::ButtonAttachment> (p.getValueTreeState(), SonobusAudioProcessor::paramSyncMetToFilePlayback, *mMetSyncFileButton);


processor.getValueTreeState().addParameterListener (SonobusAudioProcessor::paramMainSendMute, this);
Expand Down Expand Up @@ -1117,6 +1127,7 @@ SonobusAudioProcessorEditor::SonobusAudioProcessorEditor (SonobusAudioProcessor&
mMetContainer->addAndMakeVisible(mMetLevelSliderLabel.get());
mMetContainer->addAndMakeVisible(mMetTempoSliderLabel.get());
mMetContainer->addAndMakeVisible(mMetSendButton.get());
mMetContainer->addAndMakeVisible(mMetSyncFileButton.get());

if (!JUCEApplicationBase::isStandaloneApp()) {
mMetContainer->addAndMakeVisible(mMetSyncButton.get());
Expand Down Expand Up @@ -2632,10 +2643,10 @@ void SonobusAudioProcessorEditor::showMetConfig(bool flag)
Component* dw = this;

#if JUCE_IOS || JUCE_ANDROID
const int defWidth = 230;
const int defWidth = 250;
const int defHeight = 96;
#else
const int defWidth = 210;
const int defWidth = 230;
const int defHeight = 86;
#endif

Expand Down Expand Up @@ -4230,11 +4241,18 @@ void SonobusAudioProcessorEditor::updateLayout()
metTempoBox.items.add(FlexItem(minKnobWidth, knoblabelheight, *mMetTempoSliderLabel).withMargin(0).withFlex(0));
metTempoBox.items.add(FlexItem(minKnobWidth, minitemheight, *mMetTempoSlider).withMargin(0).withFlex(1));

metSendBox.items.clear();
metSendBox.flexDirection = FlexBox::Direction::column;
metSendSyncBox.items.clear();
metSendSyncBox.flexDirection = FlexBox::Direction::row;
if (!JUCEApplicationBase::isStandaloneApp()) {
metSendBox.items.add(FlexItem(60, minitemheight, *mMetSyncButton).withMargin(0).withFlex(0));
metSendSyncBox.items.add(FlexItem(40, minitemheight, *mMetSyncButton).withMargin(0).withFlex(1));
metSendSyncBox.items.add(FlexItem(2, 5).withMargin(0).withFlex(0));
}
metSendSyncBox.items.add(FlexItem(40, minitemheight, *mMetSyncFileButton).withMargin(0).withFlex(1));


metSendBox.items.clear();
metSendBox.flexDirection = FlexBox::Direction::column;
metSendBox.items.add(FlexItem(80, minitemheight, metSendSyncBox).withMargin(0).withFlex(0));
metSendBox.items.add(FlexItem(5, 5).withMargin(0).withFlex(1));
metSendBox.items.add(FlexItem(60, minitemheight, *mMetSendButton).withMargin(0).withFlex(0));

Expand All @@ -4243,7 +4261,7 @@ void SonobusAudioProcessorEditor::updateLayout()
metBox.items.add(FlexItem(minKnobWidth, minitemheight, metTempoBox).withMargin(0).withFlex(1));
metBox.items.add(FlexItem(minKnobWidth, minitemheight, metVolBox).withMargin(0).withFlex(1));
metBox.items.add(FlexItem(3, 6).withMargin(0).withFlex(0));
metBox.items.add(FlexItem(60, minitemheight, metSendBox).withMargin(2).withFlex(1));
metBox.items.add(FlexItem(80, minitemheight, metSendBox).withMargin(2).withFlex(1));


// effects
Expand Down
3 changes: 3 additions & 0 deletions Source/SonobusPluginEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ public PeersContainerView::Listener
std::unique_ptr<SonoDrawableButton> mMetEnableButton;
std::unique_ptr<SonoDrawableButton> mMetSendButton;
std::unique_ptr<TextButton> mMetSyncButton;
std::unique_ptr<TextButton> mMetSyncFileButton;
std::unique_ptr<Label> mMetTempoSliderLabel;
std::unique_ptr<Slider> mMetTempoSlider;
std::unique_ptr<Label> mMetLevelSliderLabel;
Expand Down Expand Up @@ -599,6 +600,7 @@ public PeersContainerView::Listener
FlexBox metVolBox;
FlexBox metTempoBox;
FlexBox metSendBox;
FlexBox metSendSyncBox;

FlexBox effectsBox;
FlexBox reverbBox;
Expand Down Expand Up @@ -649,6 +651,7 @@ public PeersContainerView::Listener
std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> mMainRecvMuteAttachment;
std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> mMetTempoAttachment;
std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> mMetSyncAttachment;
std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> mMetSyncFileAttachment;
std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> mMetLevelAttachment;
std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> mMetEnableAttachment;
std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> mMetSendAttachment;
Expand Down
28 changes: 26 additions & 2 deletions Source/SonobusPluginProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ String SonobusAudioProcessor::paramDynamicResampling ("dynamicresampling");
String SonobusAudioProcessor::paramAutoReconnectLast ("reconnectlast");
String SonobusAudioProcessor::paramDefaultPeerLevel ("defPeerLevel");
String SonobusAudioProcessor::paramSyncMetToHost ("syncMetHost");
String SonobusAudioProcessor::paramSyncMetToFilePlayback ("syncMetFile");
String SonobusAudioProcessor::paramInputReverbLevel ("inreverblevel");
String SonobusAudioProcessor::paramInputReverbSize ("inreverbsize");
String SonobusAudioProcessor::paramInputReverbDamping ("inreverbdamp");
Expand Down Expand Up @@ -664,6 +665,7 @@ mState (*this, &mUndoManager, "SonoBusAoO",
std::make_unique<AudioParameterFloat>(paramInputReverbPreDelay, TRANS ("Input Reverb Pre-Delay Time"), NormalisableRange<float>(0.0, 100.0, 1.0, 1.0), mInputReverbPreDelay.get(), "", AudioProcessorParameter::genericParameter,
[](float v, int maxlen) -> String { return String(v, 0) + " ms"; },
[](const String& s) -> float { return s.getFloatValue(); }),
std::make_unique<AudioParameterBool>(paramSyncMetToFilePlayback, TRANS ("Sync Met to File Playback"), false),

})
{
Expand Down Expand Up @@ -698,6 +700,7 @@ mState (*this, &mUndoManager, "SonoBusAoO",
mState.addParameterListener (paramMainMonitorSolo, this);
mState.addParameterListener (paramDefaultPeerLevel, this);
mState.addParameterListener (paramSyncMetToHost, this);
mState.addParameterListener (paramSyncMetToFilePlayback, this);
mState.addParameterListener (paramInputReverbSize, this);
mState.addParameterListener (paramInputReverbLevel, this);
mState.addParameterListener (paramInputReverbDamping, this);
Expand Down Expand Up @@ -6232,6 +6235,9 @@ void SonobusAudioProcessor::parameterChanged (const String &parameterID, float n
else if (parameterID == paramSyncMetToHost) {
mSyncMetToHost = newValue > 0;
}
else if (parameterID == paramSyncMetToFilePlayback) {
mSyncMetStartToPlayback = newValue > 0;
}
else if (parameterID == paramSendChannels) {
mSendChannels = (int) newValue;

Expand Down Expand Up @@ -7022,6 +7028,7 @@ void SonobusAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer
posInfo.bpm = mMetTempo.get();

bool syncmethost = mSyncMetToHost.get();
bool syncmetplayback = mSyncMetStartToPlayback.get();

AudioPlayHead * playhead = getPlayHead();
bool posValid = playhead && playhead->getCurrentPosition(posInfo);
Expand Down Expand Up @@ -7222,6 +7229,8 @@ void SonobusAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer
// file playback goes to everyone

bool hasfiledata = false;
double transportPos = mTransportSource.getCurrentPosition();

if (mTransportSource.getTotalLength() > 0)
{
AudioSourceChannelInfo info (&fileBuffer, 0, numSamples);
Expand Down Expand Up @@ -7283,17 +7292,28 @@ void SonobusAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer
}

}



// process metronome
bool metenabled = mMetEnabled.get();
float metgain = mMetGain.get();
double mettempo = mMetTempo.get();
bool metrecorded = mMetIsRecorded.get();
bool dometfilesyncstart = syncmetplayback && mTransportWasPlaying != mTransportSource.isPlaying();
bool syncmet = (syncmethost && hostPlaying) || (syncmetplayback && mTransportSource.isPlaying());

if (dometfilesyncstart) {
metenabled = mTransportSource.isPlaying();
mMetEnabled = metenabled;
// notify host
mState.getParameter(paramMetEnabled)->setValueNotifyingHost(metenabled ? 1.0f : 0.0f);
}

if (metenabled != mLastMetEnabled) {
if (metenabled) {
mMetronome->setGain(metgain, true);
if (!syncmethost || !hostPlaying) {
if (!syncmet) {
mMetronome->resetRelativeStart();
}
} else {
Expand All @@ -7309,7 +7329,10 @@ void SonobusAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer
if (syncmethost && hostPlaying) {
beattime = posInfo.ppqPosition;
}
mMetronome->processMix(numSamples, metBuffer.getWritePointer(0), metBuffer.getWritePointer(mainBusOutputChannels > 1 ? 1 : 0), beattime, !syncmethost || !hostPlaying);
else if (syncmetplayback && mTransportSource.isPlaying()) {
beattime = (mettempo / 60.0) * transportPos;
}
mMetronome->processMix(numSamples, metBuffer.getWritePointer(0), metBuffer.getWritePointer(mainBusOutputChannels > 1 ? 1 : 0), beattime, !syncmet);

//

Expand Down Expand Up @@ -7981,6 +8004,7 @@ void SonobusAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer
mLastInMonMonoPan = inmonMonoPan;
mAnythingSoloed = anysoloed;

mTransportWasPlaying = mTransportSource.isPlaying();
}

//==============================================================================
Expand Down
3 changes: 3 additions & 0 deletions Source/SonobusPluginProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ class SonobusAudioProcessor : public AudioProcessor, public AudioProcessorValue
static String paramAutoReconnectLast;
static String paramDefaultPeerLevel;
static String paramSyncMetToHost;
static String paramSyncMetToFilePlayback;
static String paramInputReverbLevel;
static String paramInputReverbSize;
static String paramInputReverbDamping;
Expand Down Expand Up @@ -910,6 +911,7 @@ class SonobusAudioProcessor : public AudioProcessor, public AudioProcessorValue
Atomic<bool> mAutoReconnectLast { false };
Atomic<float> mDefUserLevel { 1.0f };
Atomic<bool> mSyncMetToHost { false };
Atomic<bool> mSyncMetStartToPlayback { false };

Atomic<float> mInputReverbLevel { 1.0f };
Atomic<float> mInputReverbSize { 0.15f };
Expand Down Expand Up @@ -1136,6 +1138,7 @@ class SonobusAudioProcessor : public AudioProcessor, public AudioProcessorValue
AudioFormatManager mFormatManager;
TimeSliceThread mDiskThread { "audio file reader" };
URL mCurrTransportURL;
bool mTransportWasPlaying = false;

// metronome
std::unique_ptr<SonoAudio::Metronome> mMetronome;
Expand Down
6 changes: 3 additions & 3 deletions deps/juce/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[subrepo]
remote = https://github.com/essej/JUCE.git
branch = sono6good
commit = 8271412801918140e1eec47835901e4f4ed2efdb
commit = 995da8b9e332cea069add7ea305c4d0f7622ee61
method = merge
cmdver = 0.4.1
parent = 01e0c57d51d7ddd7a8b371c02e3f896fe7be1a0a
cmdver = 0.4.3
parent = b5ee229692e5d221accbd20fe6bbacccfcbb4056
Loading

0 comments on commit 872f911

Please sign in to comment.