diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5d4a7190e..58a21862b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,7 +5,6 @@ project(musikbox)
set (musikbox_VERSION_MAJOR 0)
set (musikbox_VERSION_MINOR 1)
-set (CMAKE_MODULE_PATH ${musikbox_SOURCE_DIR}/modules)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-fpermissive -g")
set (BOOST_LIBS
diff --git a/CMakeLists.txt.user b/CMakeLists.txt.user
new file mode 100644
index 000000000..96544b8e5
--- /dev/null
+++ b/CMakeLists.txt.user
@@ -0,0 +1,384 @@
+
+
+
+
+
+ EnvironmentId
+ {51a1da43-0d14-48ff-8564-c0a796ce556f}
+
+
+ ProjectExplorer.Project.ActiveTarget
+ 0
+
+
+ ProjectExplorer.Project.EditorSettings
+
+ true
+ false
+ true
+
+ Cpp
+
+ CppGlobal
+
+
+
+ QmlJS
+
+ QmlJSGlobal
+
+
+ 2
+ UTF-8
+ false
+ 4
+ false
+ 80
+ true
+ true
+ 1
+ true
+ false
+ 0
+ true
+ true
+ 0
+ 8
+ true
+ 1
+ true
+ true
+ true
+ false
+
+
+
+ ProjectExplorer.Project.PluginSettings
+
+
+
+
+
+ ProjectExplorer.Project.Target.0
+
+ Desktop
+ Desktop
+ {d29141ba-0196-43f4-b31a-1822393bd232}
+ 0
+ 0
+ 0
+
+
+ CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable}
+ QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable}
+
+ /Users/clangen/src/build-musikcube-Desktop-Default
+
+
+
+
+ all
+
+ true
+ Make
+
+ CMakeProjectManager.MakeStep
+
+ 1
+ Build
+
+ ProjectExplorer.BuildSteps.Build
+
+
+
+
+
+ all
+
+ true
+ Make
+
+ CMakeProjectManager.MakeStep
+
+ 1
+ Clean
+
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ Default
+ Default
+ CMakeProjectManager.CMakeBuildConfiguration
+
+
+
+ CMAKE_BUILD_TYPE:STRING=Debug
+ CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable}
+ QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable}
+
+ /Users/clangen/src/build-musikcube-Desktop-Debug
+
+
+
+
+ all
+
+ true
+ Make
+
+ CMakeProjectManager.MakeStep
+
+ 1
+ Build
+
+ ProjectExplorer.BuildSteps.Build
+
+
+
+
+
+ all
+
+ true
+ Make
+
+ CMakeProjectManager.MakeStep
+
+ 1
+ Clean
+
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ Debug
+ Debug
+ CMakeProjectManager.CMakeBuildConfiguration
+
+
+
+ CMAKE_BUILD_TYPE:STRING=Release
+ CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable}
+ QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable}
+
+ /Users/clangen/src/build-musikcube-Desktop-Release
+
+
+
+
+
+
+ true
+ Make
+
+ CMakeProjectManager.MakeStep
+
+ 1
+ Build
+
+ ProjectExplorer.BuildSteps.Build
+
+
+
+
+
+ clean
+
+ true
+ Make
+
+ CMakeProjectManager.MakeStep
+
+ 1
+ Clean
+
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ Release
+ Release
+ CMakeProjectManager.CMakeBuildConfiguration
+
+
+
+ CMAKE_BUILD_TYPE:STRING=RelWithDebInfo
+ CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable}
+ QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable}
+
+ /Users/clangen/src/build-musikcube-Desktop-Release with Debug Information
+
+
+
+
+
+
+ true
+ Make
+
+ CMakeProjectManager.MakeStep
+
+ 1
+ Build
+
+ ProjectExplorer.BuildSteps.Build
+
+
+
+
+
+ clean
+
+ true
+ Make
+
+ CMakeProjectManager.MakeStep
+
+ 1
+ Clean
+
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ Release with Debug Information
+ Release with Debug Information
+ CMakeProjectManager.CMakeBuildConfiguration
+
+
+
+ CMAKE_BUILD_TYPE:STRING=MinSizeRel
+ CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable}
+ QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable}
+
+ /Users/clangen/src/build-musikcube-Desktop-Minimum Size Release
+
+
+
+
+ all
+
+ true
+ Make
+
+ CMakeProjectManager.MakeStep
+
+ 1
+ Build
+
+ ProjectExplorer.BuildSteps.Build
+
+
+
+
+
+ all
+
+ true
+ Make
+
+ CMakeProjectManager.MakeStep
+
+ 1
+ Clean
+
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ Minimum Size Release
+ Minimum Size Release
+ CMakeProjectManager.CMakeBuildConfiguration
+
+ 5
+
+
+ 0
+ Deploy
+
+ ProjectExplorer.BuildSteps.Deploy
+
+ 1
+ Deploy locally
+
+ ProjectExplorer.DefaultDeployConfiguration
+
+ 1
+
+
+ false
+ false
+ 1000
+
+ true
+
+ false
+ false
+ false
+ false
+ true
+ 0.01
+ 10
+ true
+ 1
+ 25
+
+ 1
+ true
+ false
+ true
+ valgrind
+
+ 0
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+ 10
+ 11
+ 12
+ 13
+ 14
+
+ 2
+
+
+
+ %{buildDir}
+ Custom Executable
+
+ ProjectExplorer.CustomExecutableRunConfiguration
+ 3768
+ false
+ true
+ false
+ false
+ true
+
+ 1
+
+
+
+ ProjectExplorer.Project.TargetCount
+ 1
+
+
+ ProjectExplorer.Project.Updater.FileVersion
+ 18
+
+
+ Version
+ 18
+
+
diff --git a/musikbox.cbp b/musikbox.cbp
new file mode 100644
index 000000000..d7d187db5
--- /dev/null
+++ b/musikbox.cbp
@@ -0,0 +1,1070 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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+
diff --git a/src/contrib/coreaudioout/CoreAudioOut.cpp b/src/contrib/coreaudioout/CoreAudioOut.cpp
index 71b0a0199..5f35cc2d4 100644
--- a/src/contrib/coreaudioout/CoreAudioOut.cpp
+++ b/src/contrib/coreaudioout/CoreAudioOut.cpp
@@ -29,6 +29,7 @@ CoreAudioOut::CoreAudioOut() {
this->bufferProvider = NULL;
this->quit = false;
this->bufferCount = 0;
+ this->volume = 1.0f;
this->audioFormat = (AudioStreamBasicDescription) { 0 };
@@ -85,6 +86,8 @@ bool CoreAudioOut::Play(IBuffer *buffer, IBufferProvider *provider) {
result = AudioQueueStart(this->audioQueue, NULL);
+ this->SetVolume(volume);
+
if (result != 0) {
std::cerr << "AudioQueueStart failed: " << result << "\n";
return false;
@@ -152,6 +155,8 @@ void CoreAudioOut::Resume() {
void CoreAudioOut::SetVolume(double volume) {
boost::recursive_mutex::scoped_lock lock(this->mutex);
+ this->volume = volume;
+
if (this->audioQueue) {
OSStatus result = AudioQueueSetParameter(
this->audioQueue,
@@ -160,7 +165,6 @@ void CoreAudioOut::SetVolume(double volume) {
if (result != 0) {
std::cerr << "AudioQueueSetParameter(volume) failed: " << result << "\n";
-
}
}
}
diff --git a/src/contrib/coreaudioout/CoreAudioOut.h b/src/contrib/coreaudioout/CoreAudioOut.h
index 20742c64f..db080ec09 100644
--- a/src/contrib/coreaudioout/CoreAudioOut.h
+++ b/src/contrib/coreaudioout/CoreAudioOut.h
@@ -31,6 +31,7 @@ class CoreAudioOut : public musik::core::audio::IOutput {
musik::core::audio::IBufferProvider *bufferProvider;
AudioStreamBasicDescription audioFormat;
AudioQueueRef audioQueue;
+ double volume;
size_t bufferCount;
boost::thread thread;
boost::recursive_mutex mutex;
diff --git a/src/core/support/Common.cpp b/src/core/support/Common.cpp
index 520a6af09..37303979f 100644
--- a/src/core/support/Common.cpp
+++ b/src/core/support/Common.cpp
@@ -52,18 +52,20 @@ std::string musik::core::GetApplicationDirectory() {
std::string result;
#ifdef WIN32
- wchar_t szPath[2048];
- int iStrLength = GetModuleFileName(NULL, szPath, 2048);
- if(iStrLength != 0 && iStrLength < 2048){
- result.assign(GetPath(u16to8(szPath).c_str()));
+ wchar_t widePath[2048];
+ int length = GetModuleFileName(NULL, widePath, 2048);
+ if (length != 0 && length < 2048) {
+ result.assign(GetPath(u16to8(widePath).c_str()));
}
#else
- // char pathbuf[PATH_MAX + 1];
- // uint32_t bufsize = sizeof(pathbuf);
- // _NSGetExecutablePath(pathbuf, &bufsize);
- // result.assign(pathbuf);
- // std::cerr << result << std::endl;
- result = "/Users/clangen/src/musikcube/bin/";
+ char pathbuf[PATH_MAX + 1];
+ uint32_t bufsize = sizeof(pathbuf);
+ _NSGetExecutablePath(pathbuf, &bufsize);
+ char *resolved = realpath(pathbuf, NULL);
+ result.assign(resolved);
+ free(resolved);
+ size_t last = result.find_last_of("/");
+ result = result.substr(0, last); /* remove filename component */
#endif
return result;
@@ -77,37 +79,35 @@ std::string musik::core::GetDataDirectory() {
wchar_t *sBuffer = new wchar_t[iBufferSize + 2];
GetEnvironmentVariable(_T("APPDATA"), sBuffer, iBufferSize);
directory.assign(u16to8(sBuffer));
+ directory.append("/mC2/");
delete [] sBuffer;
#else
directory = std::string(std::getenv("HOME"));
+ directory.append("/.mC2/");
#endif
- directory.append("/mC2/");
-
- // Create folder if it does not exist
boost::filesystem::path path(directory);
- if(!boost::filesystem::exists(path)) {
+ if (!boost::filesystem::exists(path)) {
boost::filesystem::create_directories(path);
}
return directory;
}
-std::string musik::core::GetPath(const std::string &sFile){
-
+std::string musik::core::GetPath(const std::string &sFile) {
std::string sPath;
- int iStrLength;
+ int length;
#ifdef WIN32
- wchar_t szPath[2048];
+ wchar_t widePath[2048];
wchar_t *szFile = NULL;
- iStrLength = GetFullPathName(u8to16(sFile).c_str(), 2048, szPath, &szFile);
- if(iStrLength != 0 && iStrLength < 2048) {
- sPath.assign(u16to8(szPath).c_str());
+ length = GetFullPathName(u8to16(sFile).c_str(), 2048, widePath, &szFile);
+ if(length != 0 && length < 2048) {
+ sPath.assign(u16to8(widePath).c_str());
if(szFile!=0) {
std::string sTheFile = u16to8(szFile);
- sPath.assign(sPath.substr(0,iStrLength-sTheFile.length()));
+ sPath.assign(sPath.substr(0,length-sTheFile.length()));
}
}
else {
@@ -115,17 +115,17 @@ std::string musik::core::GetPath(const std::string &sFile){
}
#else //TODO: check this POSIX GetPath works
char* szDir;
- sPath.assign(getcwd((char*)szDir, (size_t) iStrLength));
+ sPath.assign(getcwd((char*)szDir, (size_t) length));
#endif //WIN32
return sPath;
}
-UINT64 musik::core::Checksum(char *data,unsigned int bytes){
- UINT64 sum(0);
- for(unsigned int i(0);iWriteChar(ch);
}
diff --git a/src/musikbox/app/util/GlobalHotkeys.cpp b/src/musikbox/app/util/GlobalHotkeys.cpp
index 3b46718d5..d793dd036 100755
--- a/src/musikbox/app/util/GlobalHotkeys.cpp
+++ b/src/musikbox/app/util/GlobalHotkeys.cpp
@@ -14,9 +14,7 @@ GlobalHotkeys::~GlobalHotkeys() {
}
-bool GlobalHotkeys::Handle(int64 ch) {
- std::string kn = keyname((int) ch);
-
+bool GlobalHotkeys::Handle(const std::string& kn) {
if (kn == "^P") {
int state = this->transport.GetPlaybackState();
if (state == Transport::PlaybackPaused) {
@@ -27,28 +25,28 @@ bool GlobalHotkeys::Handle(int64 ch) {
}
return true;
}
- if (kn == "ALT_I") {
+ if (kn == "ALT_I" || kn == "M-i") {
this->transport.SetVolume(this->transport.Volume() + 0.05); /* 5% */
return true;
}
- else if (kn == "ALT_K") {
+ else if (kn == "ALT_K" || kn == "M-k") {
this->transport.SetVolume(this->transport.Volume() - 0.05);
return true;
}
- else if (kn == "ALT_J") {
+ else if (kn == "ALT_J" || kn == "M-j") {
this->playback.Previous();
return true;
}
- else if (kn == "ALT_L") {
+ else if (kn == "ALT_L" || kn == "M-l") {
this->playback.Next();
return true;
}
- else if (kn == "ALT_U") {
+ else if (kn == "ALT_U" || kn == "M-u") {
double time = this->transport.Position();
this->transport.SetPosition(time - 10.0f);
return true;
}
- else if (kn == "ALT_O") {
+ else if (kn == "ALT_O" || kn == "M-o") {
double time = this->transport.Position();
this->transport.SetPosition(time + 10.0f);
return true;
@@ -59,4 +57,4 @@ bool GlobalHotkeys::Handle(int64 ch) {
}
return false;
-}
\ No newline at end of file
+}
diff --git a/src/musikbox/app/util/GlobalHotkeys.h b/src/musikbox/app/util/GlobalHotkeys.h
index 2009bcc53..a6ece72fb 100755
--- a/src/musikbox/app/util/GlobalHotkeys.h
+++ b/src/musikbox/app/util/GlobalHotkeys.h
@@ -10,12 +10,12 @@ namespace musik {
class GlobalHotkeys {
public:
GlobalHotkeys(
- PlaybackService& playback,
+ PlaybackService& playback,
musik::core::LibraryPtr library);
~GlobalHotkeys(); /* non-virtual; do not use as a base class */
- bool Handle(int64 ch);
+ bool Handle(const std::string& kn);
private:
PlaybackService& playback;
diff --git a/src/musikbox/app/window/CommandWindow.cpp b/src/musikbox/app/window/CommandWindow.cpp
index 98ae2b992..3318a663d 100755
--- a/src/musikbox/app/window/CommandWindow.cpp
+++ b/src/musikbox/app/window/CommandWindow.cpp
@@ -74,7 +74,7 @@ void CommandWindow::WriteChar(int64 ch) {
waddch(this->GetContent(), ch);
- if (ch == '\b') { /* backspace */
+ if (ch == '\b' || ch == 127) { /* backspace */
wdelch(this->GetContent());
if (bufferPosition > 0) {