Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
rsjaffe committed Mar 13, 2019
2 parents c348259 + 7d58c76 commit f6cde84
Show file tree
Hide file tree
Showing 17 changed files with 143 additions and 41 deletions.
4 changes: 2 additions & 2 deletions Builds/MacOSX/Info-App.plist
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleShortVersionString</key>
<string>3.0.0.10</string>
<string>3.0.0.11</string>
<key>CFBundleVersion</key>
<string>3.0.0.10</string>
<string>3.0.0.11</string>
<key>NSHumanReadableCopyright</key>
<string></string>
<key>NSHighResolutionCapable</key>
Expand Down
8 changes: 4 additions & 4 deletions Builds/MacOSX/MIDI2LR.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -951,8 +951,8 @@
"DONT_SET_USING_JUCE_NAMESPACE=1",
"GSL_THROW_ON_CONTRACT_VIOLATION=1",
"JUCER_XCODE_MAC_F6D2F4CF=1",
"JUCE_APP_VERSION=3.0.0.10",
"JUCE_APP_VERSION_HEX=0x300000a",
"JUCE_APP_VERSION=3.0.0.11",
"JUCE_APP_VERSION_HEX=0x300000b",
"JucePlugin_Build_VST=0",
"JucePlugin_Build_VST3=0",
"JucePlugin_Build_AU=0",
Expand Down Expand Up @@ -1001,8 +1001,8 @@
"DONT_SET_USING_JUCE_NAMESPACE=1",
"GSL_UNENFORCED_ON_CONTRACT_VIOLATION=1",
"JUCER_XCODE_MAC_F6D2F4CF=1",
"JUCE_APP_VERSION=3.0.0.10",
"JUCE_APP_VERSION_HEX=0x300000a",
"JUCE_APP_VERSION=3.0.0.11",
"JUCE_APP_VERSION_HEX=0x300000b",
"JucePlugin_Build_VST=0",
"JucePlugin_Build_VST3=0",
"JucePlugin_Build_AU=0",
Expand Down
4 changes: 2 additions & 2 deletions Builds/VisualStudio2017/MIDI2LR_App.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<Optimization>Disabled</Optimization>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalIncludeDirectories>..\..\JuceLibraryCode;..\..\JuceLibraryCode\modules;../../;../../icu/source/common/;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;DEBUG;_DEBUG;U_STATIC_IMPLEMENTATION=1;DONT_SET_USING_JUCE_NAMESPACE=1;GSL_THROW_ON_CONTRACT_VIOLATION=1;JUCER_VS2017_78A5024=1;JUCE_APP_VERSION=3.0.0.10;JUCE_APP_VERSION_HEX=0x300000a;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;JucePlugin_Build_Unity=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;DEBUG;_DEBUG;U_STATIC_IMPLEMENTATION=1;DONT_SET_USING_JUCE_NAMESPACE=1;GSL_THROW_ON_CONTRACT_VIOLATION=1;JUCER_VS2017_78A5024=1;JUCE_APP_VERSION=3.0.0.11;JUCE_APP_VERSION_HEX=0x300000b;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;JucePlugin_Build_Unity=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
Expand Down Expand Up @@ -105,7 +105,7 @@
<ClCompile>
<Optimization>Full</Optimization>
<AdditionalIncludeDirectories>..\..\JuceLibraryCode;..\..\JuceLibraryCode\modules;../../;../../icu/source/common/;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;NDEBUG;U_STATIC_IMPLEMENTATION=1;DONT_SET_USING_JUCE_NAMESPACE=1;GSL_UNENFORCED_ON_CONTRACT_VIOLATION=1;JUCER_VS2017_78A5024=1;JUCE_APP_VERSION=3.0.0.10;JUCE_APP_VERSION_HEX=0x300000a;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;JucePlugin_Build_Unity=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;NDEBUG;U_STATIC_IMPLEMENTATION=1;DONT_SET_USING_JUCE_NAMESPACE=1;GSL_UNENFORCED_ON_CONTRACT_VIOLATION=1;JUCER_VS2017_78A5024=1;JUCE_APP_VERSION=3.0.0.11;JUCE_APP_VERSION_HEX=0x300000b;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;JucePlugin_Build_Unity=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
Expand Down
6 changes: 3 additions & 3 deletions Builds/VisualStudio2017/resources.rc
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
#include <windows.h>

VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,0,0,10
FILEVERSION 3,0,0,11
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "FileDescription", "MIDI2LR\0"
VALUE "FileVersion", "3.0.0.10\0"
VALUE "FileVersion", "3.0.0.11\0"
VALUE "ProductName", "MIDI2LR\0"
VALUE "ProductVersion", "3.0.0.10\0"
VALUE "ProductVersion", "3.0.0.11\0"
END
END

Expand Down
4 changes: 2 additions & 2 deletions Builds/VisualStudio2019/MIDI2LR_App.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<Optimization>Disabled</Optimization>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalIncludeDirectories>..\..\JuceLibraryCode;..\..\JuceLibraryCode\modules;../../;../../icu/source/common/;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;DEBUG;_DEBUG;U_STATIC_IMPLEMENTATION=1;DONT_SET_USING_JUCE_NAMESPACE=1;GSL_THROW_ON_CONTRACT_VIOLATION=1;JUCER_VS2019_78A5026=1;JUCE_APP_VERSION=3.0.0.10;JUCE_APP_VERSION_HEX=0x300000a;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;JucePlugin_Build_Unity=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;DEBUG;_DEBUG;U_STATIC_IMPLEMENTATION=1;DONT_SET_USING_JUCE_NAMESPACE=1;GSL_THROW_ON_CONTRACT_VIOLATION=1;JUCER_VS2019_78A5026=1;JUCE_APP_VERSION=3.0.0.11;JUCE_APP_VERSION_HEX=0x300000b;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;JucePlugin_Build_Unity=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
Expand Down Expand Up @@ -105,7 +105,7 @@
<ClCompile>
<Optimization>Full</Optimization>
<AdditionalIncludeDirectories>..\..\JuceLibraryCode;..\..\JuceLibraryCode\modules;../../;../../icu/source/common/;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;NDEBUG;U_STATIC_IMPLEMENTATION=1;DONT_SET_USING_JUCE_NAMESPACE=1;GSL_UNENFORCED_ON_CONTRACT_VIOLATION=1;JUCER_VS2019_78A5026=1;JUCE_APP_VERSION=3.0.0.10;JUCE_APP_VERSION_HEX=0x300000a;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;JucePlugin_Build_Unity=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;NDEBUG;U_STATIC_IMPLEMENTATION=1;DONT_SET_USING_JUCE_NAMESPACE=1;GSL_UNENFORCED_ON_CONTRACT_VIOLATION=1;JUCER_VS2019_78A5026=1;JUCE_APP_VERSION=3.0.0.11;JUCE_APP_VERSION_HEX=0x300000b;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;JucePlugin_Build_Unity=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
Expand Down
6 changes: 3 additions & 3 deletions Builds/VisualStudio2019/resources.rc
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
#include <windows.h>

VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,0,0,10
FILEVERSION 3,0,0,11
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "FileDescription", "MIDI2LR\0"
VALUE "FileVersion", "3.0.0.10\0"
VALUE "FileVersion", "3.0.0.11\0"
VALUE "ProductName", "MIDI2LR\0"
VALUE "ProductVersion", "3.0.0.10\0"
VALUE "ProductVersion", "3.0.0.11\0"
END
END

Expand Down
2 changes: 1 addition & 1 deletion DoxyGen/Midi2lr.Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = MIDI2LR
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 3.0.0.10
PROJECT_NUMBER = 3.0.0.11

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
2 changes: 1 addition & 1 deletion Installer/MIDI2LR.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<project>
<shortName>MIDI2LR</shortName>
<fullName>MIDI2LR</fullName>
<version>3.0.0.10</version>
<version>3.0.0.11</version>
<installerFilename>${product_shortname}-${product_version}-${debuglabel}${platform_name}-installer.${platform_exec_suffix}</installerFilename>
<readmeFile>../Source/LRPlugin/ReadMe.txt</readmeFile>
<licenseFile>../LICENSE.txt</licenseFile>
Expand Down
4 changes: 2 additions & 2 deletions JuceLibraryCode/JuceHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace ProjectInfo
{
const char* const projectName = "MIDI2LR";
const char* const companyName = "";
const char* const versionString = "3.0.0.10";
const int versionNumber = 0x300000a;
const char* const versionString = "3.0.0.11";
const int versionNumber = 0x300000b;
}
#endif
2 changes: 1 addition & 1 deletion MIDI2LR.jucer
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>

<JUCERPROJECT id="jqaeel" name="MIDI2LR" projectType="guiapp" version="3.0.0.10"
<JUCERPROJECT id="jqaeel" name="MIDI2LR" projectType="guiapp" version="3.0.0.11"
bundleIdentifier="com.rsjaffe.MIDI2LR" includeBinaryInAppConfig="1"
jucerVersion="5.4.3" companyWebsite="http://rsjaffe.github.io/MIDI2LR/"
companyEmail="[email protected]" displaySplashScreen="0" reportAppUsage="0"
Expand Down
2 changes: 1 addition & 1 deletion Source/LRPlugin/MIDI2LR.lrplugin/Info.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@ return {
},

},
VERSION = { major=3, minor=0, revision=0, build=10}
VERSION = { major=3, minor=0, revision=0, build=11}
}
99 changes: 92 additions & 7 deletions Source/MIDIReceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ MIDI2LR. If not, see <http://www.gnu.org/licenses/>.
*/
#include "MIDIReceiver.h"

#include <chrono> //sleep_for timing
#include <exception>
#include <future>
#include <thread> //sleep_for

#include "Misc.h"

Expand Down Expand Up @@ -123,16 +125,99 @@ void MidiReceiver::RescanDevices()
InitDevices(); // initdevices has own try catch block
}

void MidiReceiver::TryToOpen()
{
for (auto idx = 0; idx < juce::MidiInput::getDevices().size(); ++idx) {
const auto dev = juce::MidiInput::openDevice(idx, this);
if (dev) {
devices_.emplace_back(dev);
dev->start();
rsj::Log("Opened input device " + dev->getName());
}
}
}

namespace {
// zepto yocto zetta and yotta too large/small to be represented by intmax_t
// TODO: change to consteval, find way to convert digit to string for unexpected
// values, so return could be, e.g., "23425/125557 ", instead of error message
template<class R> constexpr auto RatioToPrefix()
{
if (R::num == 1) {
switch (R::den) {
case 1:
return "";
case 10:
return "deci";
case 100:
return "centi";
case 1000:
return "milli";
case 1000000:
return "micro";
case 1000000000:
return "nano";
case 1000000000000:
return "pico";
case 1000000000000000:
return "femto";
case 1000000000000000000:
return "atto";
}
}
switch (R::num) {
case 10:
return "deca";
case 100:
return "hecto";
case 1000:
return "kilo";
case 1000000:
return "mega";
case 1000000000:
return "giga";
case 1000000000000:
return "tera";
case 1000000000000000:
return "peta";
case 1000000000000000000:
return "exa";
}
return "unexpected ratio encountered ";
}

template<class Rep, class Period>
auto SleepTimed(const std::chrono::duration<Rep, Period> sleep_duration)
{
const auto start = std::chrono::high_resolution_clock::now();
std::this_thread::sleep_for(sleep_duration);
const auto end = std::chrono::high_resolution_clock::now();
const std::chrono::duration<double, Period> elapsed = end - start;
return elapsed;
}

template<class Rep, class Period>
void SleepTimedLogged(
std::string_view msg_prefix, std::chrono::duration<Rep, Period> sleep_duration)
{
const auto elapsed = SleepTimed(sleep_duration);
rsj::Log(juce::String(msg_prefix.data(), msg_prefix.size()) + " thread slept for "
+ juce::String(elapsed.count()) + ' ' + RatioToPrefix<Period>() + "seconds.");
}

} // namespace

void MidiReceiver::InitDevices()
{
using namespace std::chrono_literals;
try {
for (auto idx = 0; idx < juce::MidiInput::getDevices().size(); ++idx) {
const auto dev = juce::MidiInput::openDevice(idx, this);
if (dev) {
devices_.emplace_back(dev);
dev->start();
rsj::Log("Opened input device " + dev->getName());
}
rsj::Log("Trying to open input devices");
TryToOpen();
if (devices_.empty()) // encountering errors first try on MacOS
{
rsj::Log("Retrying to open input devices");
SleepTimedLogged("Open input devices", 20ms);
TryToOpen();
}
}
catch (const std::exception& e) {
Expand Down
1 change: 1 addition & 0 deletions Source/MIDIReceiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class MidiReceiver final : juce::MidiInputCallback {
void handleIncomingMidiMessage(juce::MidiInput*, const juce::MidiMessage&) override;
void DispatchMessages();
void InitDevices();
void TryToOpen(); //inner code for InitDevices

moodycamel::BlockingConcurrentQueue<rsj::MidiMessage> messages_;
NrpnFilter nrpn_filter_;
Expand Down
12 changes: 12 additions & 0 deletions Source/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,16 @@ MainWindow::MainWindow(const juce::String& name, CommandMap& command_map,
juce::Component::centreWithSize(getWidth(), getHeight());
juce::Component::setVisible(true);
window_content_->Init(std::move(lr_ipc_out), std::move(midi_receiver), std::move(midi_sender));
// get the auto time setting
auto hide_sec = settings_manager.GetAutoHideTime();
// start timing
if (hide_sec) //don't start timer if time is zero!
juce::Timer::startTimer(1000 * hide_sec);
}

void MainWindow::timerCallback()
{
juce::Timer::stopTimer();
if (!juce::ResizableWindow::isMinimised())
juce::DocumentWindow::minimiseButtonPressed();
}
4 changes: 3 additions & 1 deletion Source/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class MainContentComponent;
class ProfileManager;
class SettingsManager;

class MainWindow final : juce::DocumentWindow {
class MainWindow final : juce::DocumentWindow, juce::Timer {
public:
MainWindow(const juce::String& name, CommandMap& command_map, ProfileManager& profile_manager,
SettingsManager& settings_manager, std::weak_ptr<LrIpcOut>&& lr_ipc_out,
Expand All @@ -58,6 +58,8 @@ class MainWindow final : juce::DocumentWindow {
juce::JUCEApplication::getInstance()->systemRequestedQuit();
}
MainContentComponent* window_content_;
// the timer callback function
void timerCallback() override;
};

#endif // MAINWINDOW_H_INCLUDED
6 changes: 3 additions & 3 deletions Source/Misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ std::wstring rsj::Utf8ToWide(std::string_view input)
MultiByteToWideCharErrorChecked(CP_UTF8, 0, input.data(), input.size(), nullptr, 0) + 1;
std::vector<wchar_t> buffer(buffersize, 0); // all zero
MultiByteToWideCharErrorChecked(
CP_UTF8, 0, input.data(), input.size(), buffer.data(), buffer.size());
CP_UTF8, 0, input.data(), input.size(), buffer.data(), gsl::narrow_cast<int>(buffer.size()));
return buffer.data();
}

Expand All @@ -152,8 +152,8 @@ std::string rsj::WideToUtf8(std::wstring_view wstr)
CP_UTF8, 0, wstr.data(), wstr.size(), nullptr, 0, nullptr, nullptr)
+ 1;
std::vector<char> buffer(buffersize, 0);
WideCharToMultiByteErrorChecked(
CP_UTF8, 0, wstr.data(), wstr.size(), buffer.data(), buffer.size(), nullptr, nullptr);
WideCharToMultiByteErrorChecked(CP_UTF8, 0, wstr.data(), wstr.size(), buffer.data(),
gsl::narrow_cast<int>(buffer.size()), nullptr, nullptr);
return buffer.data();
}
#else
Expand Down
18 changes: 10 additions & 8 deletions Source/SendKeys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,11 @@ namespace {
kUCKeyTranslateNoDeadKeysMask, &keys_down, sizeof(chars) / sizeof(chars[0]), &real_length,
chars);
if (real_length != 1) {
rsj::Log(juce::String("For key code ") + juce::String(key_code)
+ juce::String(", Unicode character is ") + juce::String(real_length)
+ juce::String(" long. It starts with ") + juce::String(chars[0])
+ juce::String("."));
if (real_length > 1)
rsj::Log(juce::String("For key code ") + juce::String(key_code)
+ juce::String(", Unicode character is ") + juce::String(real_length)
+ juce::String(" long. It starts with ") + juce::String(chars[0])
+ juce::String("."));
chars[0] = 0;
}
// shifted
Expand All @@ -211,10 +212,11 @@ namespace {
kUCKeyTranslateNoDeadKeysMask, &s_keys_down, sizeof(s_chars) / sizeof(s_chars[0]),
&s_real_length, s_chars);
if (s_real_length != 1) {
rsj::Log(juce::String("For shifted key code ") + juce::String(key_code)
+ juce::String(", Unicode character is ") + juce::String(s_real_length)
+ juce::String(" long. It starts with ") + juce::String(s_chars[0])
+ juce::String("."));
if (s_real_length > 1)
rsj::Log(juce::String("For shifted key code ") + juce::String(key_code)
+ juce::String(", Unicode character is ") + juce::String(s_real_length)
+ juce::String(" long. It starts with ") + juce::String(s_chars[0])
+ juce::String("."));
s_chars[0] = 0;
}
if (chars[0] == s_chars[0])
Expand Down

0 comments on commit f6cde84

Please sign in to comment.