Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Midi Input Part 1 #142

Merged
merged 13 commits into from
Oct 22, 2024
6 changes: 3 additions & 3 deletions projects/resources/RG35XXPLUS/mapping.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
enable DUMPEVENT to help with mapping
-->
<MAPPINGS>

<MAP src="but:0:4" dst="/event/lshoulder" />
<MAP src="but:0:5" dst="/event/rshoulder" />
<MAP src="but:0:5" dst="/event/rshoulder" />

<MAP src="hat:0:0:0" dst="/event/up" />
<MAP src="hat:0:0:2" dst="/event/down" />
<MAP src="hat:0:0:3" dst="/event/left" />
<MAP src="hat:0:0:1" dst="/event/right" />

<MAP src="but:0:0" dst="/event/a" />
<MAP src="but:0:1" dst="/event/b" />
<MAP src="but:0:1" dst="/event/b" />
<MAP src="but:0:7" dst="/event/start" />

</MAPPINGS>
78 changes: 28 additions & 50 deletions sources/Application/Application.cpp
Original file line number Diff line number Diff line change
@@ -1,64 +1,42 @@
#include "Application/Application.h"
#include "Application/AppWindow.h"
#include "UIFramework/Interfaces/I_GUIWindowFactory.h"
#include "Application/Persistency/PersistencyService.h"
#include "Services/Audio/Audio.h"
#include "Application.h"

#include "Application/AppWindow.h"
#include "Application/Commands/CommandDispatcher.h"
#include "Application/Controllers/ControlRoom.h"
#include "Application/Model/Config.h"
#include "Application/Persistency/PersistencyService.h"
#include "Services/Audio/Audio.h"
#include "Services/Midi/MidiService.h"

#include "UIFramework/Interfaces/I_GUIWindowFactory.h"
#include <math.h>

Application *Application::instance_=NULL ;
Application *Application::instance_ = NULL;

Application::Application() {
}

void Application::initMidiInput()
{
const char *preferedDevice=Config::GetInstance()->GetValue("MIDICTRLDEVICE");
Application::Application() {}

IteratorPtr<MidiInDevice>it(MidiService::GetInstance()->GetInIterator()) ;
for(it->Begin();!it->IsDone();it->Next())
{
MidiInDevice &in=it->CurrentItem() ;
if ((preferedDevice) && (!strncmp(in.GetName(), preferedDevice, strlen(preferedDevice))))
{
if (in.Init())
{
if (in.Start())
{
Trace::Log("MIDI","Controlling activated for MIDI interface %s",in.GetName()) ;
}
else
{
in.Close() ;
}
}
void Application::initMidiInput() {
const char *preferedDevice =
Config::GetInstance()->GetValue("MIDICTRLDEVICE");
if (preferedDevice) {
MidiService::GetInstance()->SelectDevice(preferedDevice);
}
}
}

bool Application::Init(GUICreateWindowParams &params) {
const char* root=Config::GetInstance()->GetValue("ROOTFOLDER") ;
if (root) {
Path::SetAlias("root",root) ;
} ;
window_=AppWindow::Create(params) ;
PersistencyService::GetInstance() ;
Audio *audio=Audio::GetInstance() ;
audio->Init() ;
CommandDispatcher::GetInstance()->Init() ;
initMidiInput();
ControlRoom::GetInstance()->LoadMapping("bin:mapping.xml") ;
return true ;
} ;
const char *root = Config::GetInstance()->GetValue("ROOTFOLDER");
if (root) {
Path::SetAlias("root", root);
}
window_ = AppWindow::Create(params);
PersistencyService::GetInstance();
Audio *audio = Audio::GetInstance();
audio->Init();
CommandDispatcher::GetInstance()->Init();
initMidiInput();
ControlRoom::GetInstance()->LoadMapping("bin:mapping.xml");
return true;
}

GUIWindow *Application::GetWindow() {
return window_ ;
} ;
GUIWindow *Application::GetWindow() { return window_; }

Application::~Application() {
delete window_ ;
}
Application::~Application() { delete window_; }
31 changes: 16 additions & 15 deletions sources/Application/Application.h
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
#ifndef _APPLICATION_H_
#define _APPLICATION_H_

#include "UIFramework/SimpleBaseClasses/GUIWindow.h"
#include "Foundation/T_Singleton.h"
#include "UIFramework/SimpleBaseClasses/GUIWindow.h"

class Application : public T_Singleton<Application> {

class Application:public T_Singleton<Application> {
public:
Application();
~Application();
bool Init(GUICreateWindowParams &params);

public:
Application() ;
~Application() ;
bool Init(GUICreateWindowParams &params) ;
GUIWindow *GetWindow();

GUIWindow *GetWindow() ;
protected:
void initMidiInput();
protected:
void initMidiInput();

private:
GUIWindow *window_ ;
private:
static Application* instance_ ;
} ;
private:
GUIWindow *window_;

#endif
private:
static Application *instance_;
};

#endif // _APPLICATION_H_
Loading
Loading