Commit d8870f24 authored by Michael Zbyszyński's avatar Michael Zbyszyński

Merge branch 'develop'

parents c5415bd6 f43aefc7
Subproject commit 6c3d65be199ec74753e61ec026284fd3ebc71faa
Subproject commit 3a5431836b7c8ad98459f3d6ff50e5bac1d2c297
RapidLib @ 86749bf3
Subproject commit 5e0190d65d2204ad2fae48a5120b8c2191c7d106
Subproject commit 86749bf38c0c050dd1c1ccb62c3d3654db4ac66b
......@@ -122,7 +122,7 @@ public:
header.setColour(TextButton::buttonColourId, Colours::wheat);
header.setColour(TextButton::textColourOffId, Colours::white);
header.setEnabled(false);
header.setButtonText("Rapid API Example");
header.setButtonText("RAPID-MIX API Example");
addAndMakeVisible(header);
sidebar.setColour(TextButton::buttonColourId, Colours::white);
......@@ -329,7 +329,7 @@ public:
if (KeyPress::isKeyCurrentlyDown(KeyPress::spaceKey))
{
std::vector<double> input = normaliseMouseSpace(_event.position.roundToInt(), drawingArea);
trainingExample<double> example;
trainingExample example;
example.input = { input[0], input[1] };
example.output = { modulationFrequency, modulationDepth, centreFrequency, resonance };
trainingSet.push_back(example);
......@@ -424,8 +424,8 @@ private:
/*** MACHINE LEARNING ***/
// Rapid regression
regression<double> rapidRegression;
std::vector<trainingExample<double> > trainingSet;
regression rapidRegression;
std::vector<trainingExample> trainingSet;
// Program state
bool trained;
......
......@@ -104,9 +104,9 @@
<VS2015 targetFolder="Builds/VisualStudio2015">
<CONFIGURATIONS>
<CONFIGURATION name="Debug" winWarningLevel="4" generateManifest="1" winArchitecture="32-bit"
isDebug="1" optimisation="1" targetName="RAPID_JUCE" headerPath="../../../../dependencies/Maximilian/"/>
isDebug="1" optimisation="1" targetName="regression_synth" headerPath="../../../../dependencies/Maximilian/"/>
<CONFIGURATION name="Release" winWarningLevel="4" generateManifest="1" winArchitecture="32-bit"
isDebug="0" optimisation="3" targetName="RAPID_JUCE" headerPath="../../../../dependencies/Maximilian"/>
isDebug="0" optimisation="3" targetName="regression_synth" headerPath="../../../../dependencies/Maximilian"/>
</CONFIGURATIONS>
<MODULEPATHS>
<MODULEPATH id="juce_core" path="../JUCE/modules"/>
......@@ -127,9 +127,9 @@
</VS2015>
<XCODE_MAC targetFolder="Builds/MacOSX">
<CONFIGURATIONS>
<CONFIGURATION name="Debug" isDebug="1" optimisation="1" targetName="RAPID_JUCE"
<CONFIGURATION name="Debug" isDebug="1" optimisation="1" targetName="regression_synth"
headerPath="../../../../dependencies/Maximilian"/>
<CONFIGURATION name="Release" isDebug="0" optimisation="3" targetName="RAPID_JUCE"
<CONFIGURATION name="Release" isDebug="0" optimisation="3" targetName="regression_synth"
headerPath="../../../../dependencies/Maximilian"/>
</CONFIGURATIONS>
<MODULEPATHS>
......@@ -149,6 +149,28 @@
<MODULEPATH id="juce_audio_basics" path="../JUCE/modules"/>
</MODULEPATHS>
</XCODE_MAC>
<LINUX_MAKE targetFolder="Builds/LinuxMakefile">
<CONFIGURATIONS>
<CONFIGURATION name="Debug" isDebug="1" optimisation="1" targetName="regression_synth"/>
<CONFIGURATION name="Release" isDebug="0" optimisation="3" targetName="regression_synth"/>
</CONFIGURATIONS>
<MODULEPATHS>
<MODULEPATH id="juce_video" path="../JUCE/modules"/>
<MODULEPATH id="juce_opengl" path="../JUCE/modules"/>
<MODULEPATH id="juce_gui_extra" path="../JUCE/modules"/>
<MODULEPATH id="juce_gui_basics" path="../JUCE/modules"/>
<MODULEPATH id="juce_graphics" path="../JUCE/modules"/>
<MODULEPATH id="juce_events" path="../JUCE/modules"/>
<MODULEPATH id="juce_data_structures" path="../JUCE/modules"/>
<MODULEPATH id="juce_cryptography" path="../JUCE/modules"/>
<MODULEPATH id="juce_core" path="../JUCE/modules"/>
<MODULEPATH id="juce_audio_utils" path="../JUCE/modules"/>
<MODULEPATH id="juce_audio_processors" path="../JUCE/modules"/>
<MODULEPATH id="juce_audio_formats" path="../JUCE/modules"/>
<MODULEPATH id="juce_audio_devices" path="../JUCE/modules"/>
<MODULEPATH id="juce_audio_basics" path="../JUCE/modules"/>
</MODULEPATHS>
</LINUX_MAKE>
</EXPORTFORMATS>
<MODULES>
<MODULE id="juce_audio_basics" showAllCode="1" useLocalCopy="0" useGlobalPath="1"/>
......
<group>
<0>100</0>
<1>0</1>
<2>44</2>
<3>0</3>
<4>100</4>
<5>0</5>
<6>45</6>
<7>0</7>
<8>100</8>
<9>0</9>
<10>45</10>
<11>0</11>
</group>
#include "ofMain.h"
#include "ofApp.h"
//========================================================================
int main( ){
ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context
// this kicks off the running of my app
// can be OF_WINDOW or OF_FULLSCREEN
// pass in width and height too:
ofRunApp(new ofApp());
}
This diff is collapsed.
#pragma once
#include <vector>
#include "ofMain.h"
#include "ofxGui.h"
#include "ofxMyo.h"
#include "ofxMaxim.h"
#include "regression.h"
#include "rapidStream.h"
class ofApp : public ofBaseApp{
public:
void setup();
void update();
void draw();
void exit();
void keyPressed(int key);
void keyReleased(int key);
void mouseMoved(int x, int y );
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void mouseEntered(int x, int y);
void mouseExited(int x, int y);
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
void probsClearPressed();
void resetModelPressed();
ofxIntSlider thung0, thung1, thung2, thung3;
ofxIntSlider thung4, thung5, thung6, thung7;
ofxIntSlider thung8, thung9, thung10, thung11;
std::vector<ofxIntSlider> thungs;
ofxPanel guiThung;
ofxIntSlider tong0, tong1, tong2, tong3;
ofxIntSlider tong4, tong5, tong6, tong7;
ofxIntSlider tong8, tong9, tong10, tong11;
ofxPanel guiTong;
ofxFloatSlider gain;
ofxToggle inputDevice;
ofxToggle modelControl;
ofxButton resetModel;
ofxButton probsClear;
ofxPanel guiGeneral;
std::vector<ofxIntSlider> allSliders;
//Maxi
void audioOut(float * output, int bufferSize, int nChannels);
//void audioIn(float * input, int bufferSize, int nChannels);
int bufferSize;
int initialBufferSize;
int sampleRate;
private:
ofxMyo::Myo myo;
//---------Maxi---------------//
double outputs[2];
maxiSample saron_sbpl1;
maxiSample saron_sbpl2;
maxiSample saron_sbpl3;
maxiSample saron_sbpl4;
maxiSample saron_sbpl5;
maxiSample ciblon_tong;
maxiSample ciblon_thung;
maxiClock myClock;
int currentBeat;
//---------RapidLib---------------//
regression myNN;
std::vector<trainingExample> trainingSet;
int recordingState;
bool trained;
rapidStream streamBuf = rapidStream(25);
};
......@@ -19,11 +19,11 @@ namespace rapidmix {
/////////////////////////////////////////////////////////////////////// RapidLib specializations
void trainingData2rapidLib (const trainingData &newTrainingData, std::vector<trainingExample<double> > &trainingSet) {
void trainingData2rapidLib (const trainingData &newTrainingData, std::vector<trainingExample> &trainingSet) {
for (int h = 0; h < newTrainingData.trainingSet.size(); ++h) { //Go through every phrase
for (int i = 0; i < newTrainingData.trainingSet[h].elements.size(); ++i) { //...and every element
trainingExample<double> tempExample;
trainingExample tempExample;
tempExample.input = newTrainingData.trainingSet[h].elements[i].input;
if (newTrainingData.trainingSet[h].elements[i].output.size() > 0) {
tempExample.output = newTrainingData.trainingSet[h].elements[i].output;
......@@ -37,8 +37,8 @@ namespace rapidmix {
/////////////////////////////////////////////////////////////////////// RapidLib classification
template<>
bool machineLearning<classification<double>>::train(const trainingData &newTrainingData) {
std::vector<trainingExample<double> > trainingSet;
bool machineLearning<classification>::train(const trainingData &newTrainingData) {
std::vector<trainingExample> trainingSet;
labels.clear();
for (int i = 0; i < newTrainingData.trainingSet.size(); ++i) {
labels.push_back(newTrainingData.trainingSet[i].label);
......@@ -49,18 +49,18 @@ namespace rapidmix {
/////////////////////////////////////////////////////////////////////// RapidLib regression
template<>
bool machineLearning<regression<double> >::train(const trainingData &newTrainingData) {
std::vector<trainingExample<double> > trainingSet;
bool machineLearning<regression>::train(const trainingData &newTrainingData) {
std::vector<trainingExample> trainingSet;
trainingData2rapidLib(newTrainingData, trainingSet);
return regression::train(trainingSet);
}
/////////////////////////////////////////////////////////////////////// RapidLib seriesClassification
template<>
bool machineLearning<seriesClassification<double> >::train(const trainingData &newTrainingData) {
std::vector<trainingSeries<double> > seriesSet;
bool machineLearning<seriesClassification>::train(const trainingData &newTrainingData) {
std::vector<trainingSeries> seriesSet;
for (int i = 0; i < newTrainingData.trainingSet.size(); ++i) { //each phrase
trainingSeries<double> tempSeries;
trainingSeries tempSeries;
tempSeries.label = newTrainingData.trainingSet[i].label;
for (int j = 0; j < newTrainingData.trainingSet[i].elements.size(); ++j) { //each element
tempSeries.input.push_back(newTrainingData.trainingSet[i].elements[j].input);
......@@ -71,13 +71,13 @@ namespace rapidmix {
}
template<>
std::string machineLearning<classification<double> >::run(const std::vector<double> &inputVector, const std::string &label) {
std::string machineLearning<classification>::run(const std::vector<double> &inputVector, const std::string &label) {
int classIndex = classification::run(inputVector)[0];
return labels[classIndex];
};
template<>
std::string machineLearning<seriesClassification<double> >::run(const std::vector<std::vector<double> > &inputSeries) {
std::string machineLearning<seriesClassification>::run(const std::vector<std::vector<double> > &inputSeries) {
return seriesClassification::run(inputSeries);
}
......
......@@ -79,13 +79,13 @@ namespace rapidmix {
///// RapidLib
/** @brief static classification using KNN from RapidLib */
typedef machineLearning<classification<double> > staticClassification;
typedef machineLearning<classification> staticClassification;
/** @brief static regression using Neural Networks from RapidLib */
typedef machineLearning<regression<double> > staticRegression;
typedef machineLearning<regression> staticRegression;
/** @brief temporal classification using Dynamic Time Warping from RapidLib */
typedef machineLearning<seriesClassification<double> > dtwTemporalClassification;
typedef machineLearning<seriesClassification> dtwTemporalClassification;
///// XMM
......
......@@ -128,19 +128,19 @@ SCENARIO("Test DTW classification", "[machineLearning]")
REQUIRE(myData.addElement(input, output) == 5);
myData.stopRecording();
myData.startRecording("setTwo");
//alternate API
auto setTwo = myData.createNewPhrase("setTwo");
input = { 1., 4. };
myData.addElement(input, output);
setTwo->addElement(input, output);
input = { 2., -3. };
myData.addElement(input, output);
setTwo->addElement(input, output);
input = { 1., 5. };
myData.addElement(input, output);
setTwo->addElement(input, output);
input = { -2., 1. };
myData.addElement(input, output);
myData.stopRecording();
setTwo->addElement(input, output);
REQUIRE(myDTW.train(myData) == true);
std::vector<std::vector<double> > inputSet1;
inputSet1.push_back( {1., 4.});
inputSet1.push_back( {2., -3.});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment