This GitLab instance reached the end of its service life. It won't be possible to create new users or projects.

Please read the deprecation notice for more information concerning the deprecation timeline

Visit migration.git.tu-berlin.de (internal network only) to import your old projects to the new GitLab platform 📥

Commit 088342bd by Henrik von Coler

Added MIDI tester!

parent bbd70ad8
......@@ -19,18 +19,16 @@ OscMan::OscMan(int p)
port = p;
speed = 0;
speed = 0.05;
st = new lo::ServerThread(port);
if (st->is_valid())
{
// Add the example handler to the server!
st->add_method("/speed", "f", speed_callback, this);
// start, obviously
st->start();
std::cout << "Started OSC Server!" << std::endl;
}
......
# define the compiler
CC = g++
# path(s) to include files
CFLAGS = -I.
# libraries to link
LDFLAGS = -lrtmidi
SRCS = main.cpp midiman.cpp
DEPS = datatypes.h midiman.h
all: midi_tester
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
midi_tester: main.o midiman.o
$(CC) -o midi_tester main.o midiman.o $(LDFLAGS)
clean:
rm *.o midi_tester
/**
* \struct noteMessage
*
*
* \brief Structure for holding Note (on,off) messages.
*
*
* \author Henrik von Coler
*
* \version $Revision: 0.5 $
*
* \date $Date: 2005/04/14 14:16:20 $
*
* Contact: von_coler@intelligent-noise-solutions.de
*
*
*/
#ifndef DATATYPES_H
#define DATATYPES_H
typedef struct {
int noteNumber = -1; /// @var noteNumber The note number
double velocity = -1;
bool hasBeenProcessed = false;
}noteMessage;
typedef struct {
int ctlNumber = -1; /// @var noteNumber The note number
double value = -1;
bool hasBeenProcessed = false;
}ctlMessage;
#endif // DATATYPES_H
#include <cstring>
#include <iostream>
#include <unistd.h>
#include "midiman.h"
using std::cout;
using std::endl;
int main(int argc, char *argv[]){
int id;
for (int i = 1; i < argc; i++)
{
if (i + 1 != argc)
{
if (strcmp(argv[i], "-ID") == 0)
{
id = atoi(argv[i + 1]);
i++;
}
}
}
MidiMan * m = new MidiMan(id);
while(1)
{
m->get_midi_messages();
m->flushProcessedMessages();
usleep(50);
}
}
#include "midiman.h"
bool MidiMan::done;
MidiMan::MidiMan(int device_ID)
{
// rtmidid intit
midiin = new RtMidiIn(RtMidiIn::Api::UNSPECIFIED ,std::string("RtMidi Input Client"),(unsigned int) 100);
//
unsigned int nPorts = midiin->getPortCount();
midiin->openPort(device_ID);
// Don't ignore sysex, timing, or active sensing messages.
midiin->ignoreTypes( false, false, false );
done = false;
}
void MidiMan::setVerbose()
{
isVerbose = true;
}
MidiMan::midiMessage MidiMan::get_midi_messages()
{
MidiMan::midiMessage mm;
std::vector<unsigned char> a;
int nBytes = 1;
/// this is kind of a dirty workaroud -
/// we loop over all in-massages and take the last one:
while(nBytes>0)
{
midiin->getMessage(&a);
nBytes = a.size();
/// only do something if bytes are received
if(nBytes!=0)
{
/// only give feedback if 'verbose-mode' is active
if(isVerbose == true )
{
std::cout << "Received " << nBytes << " Bytes: " ;
for (int i=0; i<nBytes; i++ )
std::cout << i << " = " << (int)a[i] << " -- " ;
std::cout << std::endl;
}
mm.byte1 = a[0];
mm.byte2 = a[1];
mm.byte3 = a[2];
}
}
return mm;
}
//////////////////////////////////////////////////////////////////
// FLUSH
//////////////////////////////////////////////////////////////////
void MidiMan::flushProcessedMessages()
{
val.clear();
}
int MidiMan::getNumFaderMessages()
{
int v = (int) val.size();
return v;
}
/**
* \class MidiMan
*
*
* \brief Class which parses and stores the incoming MIDI messages.
*
*
* \author Henrik von Coler
*
* \version $Revision: 0.5 $
*
* \date $Date: 2005/04/14 14:16:20 $
*
* Contact: von_coler@tu-berlin.de
*
*
*/
#ifndef MIDIMAN_H
#define MIDIMAN_H
#include <iostream>
#include <cstdlib>
#include <signal.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <iostream>
#include <jack/midiport.h>
#include <rtmidi/RtMidi.h>
#include "datatypes.h"
class MidiMan
{
public:
typedef struct {
int byte1 = -1;
int byte2 = -1;
double byte3 = -1;
bool hasBeenProcessed = false;
}midiMessage;
MidiMan(int device_ID);
~MidiMan();
std::vector<std::string> returnAllNames();
void updateMidiMessages(void *port_buf);
void parseMidiMessages();
void addNoteOnMessage(int in[3]);
std::vector<noteMessage> getNoteOnMessages();
void clearNoteOnMessages();
void addNoteOffMessage(int in[3]);
std::vector<noteMessage> getNoteOffMessages();
void clearNoteOffMessages();
void eraseNoteOnMessage(int position);
void addFaderMessage(ctlMessage m);
void markOnMessageProcessed(int pos);
void markOffMessageProcessed(int pos);
void flushProcessedMessages();
ctlMessage getLastFaderMessage();
int getNumFaderMessages();
static void finish(int ignore);
midiMessage get_midi_messages();
void setVerbose();
private:
// rtmidi
static bool done;
RtMidiIn *midiin;
int nBytes, i;
double stamp;
bool isVerbose = true;
std::vector<int> val;
noteMessage *tmpNote;
void mycallback( double deltatime, std::vector< unsigned char > *message, void *userData );
};
#endif // MIDIMAN_H
......@@ -2,4 +2,4 @@
#
# called by synth-user.service
#
/home/student/examples/wav_example/wav_example -f /home/student/wav/ALF_8bitDRY.wav
/home/student/examples/granular_example/granular_example -f /home/student/wav/startup.wav -l 1000 -n 4
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