summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/LV2-render.c64
-rw-r--r--src/LV2-render_console.c15
-rw-r--r--src/LV2-render_internal.h1
-rw-r--r--src/midi/NOTES84
-rw-r--r--src/midi/example.midbin93565 -> 0 bytes
-rw-r--r--src/midi/example1.midbin9285 -> 0 bytes
-rw-r--r--src/midi/example2.midbin21504 -> 0 bytes
-rw-r--r--src/midi/fluid_midi.c38
-rw-r--r--src/midi/fluid_midi.h5
-rw-r--r--src/midi/midi_loader.c26
-rw-r--r--src/midi/midi_loader.h17
-rw-r--r--src/midi/midi_loader_test.c2
12 files changed, 50 insertions, 202 deletions
diff --git a/src/LV2-render.c b/src/LV2-render.c
index d909099..490f1ae 100644
--- a/src/LV2-render.c
+++ b/src/LV2-render.c
@@ -78,6 +78,7 @@
#include "midi/midi_loader.h"
#include "midi/fluidsynth_priv.h"
+#define DEBUG 0
int min(int x, int y) {
return (x < y) ? x : y;
@@ -139,12 +140,7 @@ int process_midi_cb(fluid_midi_event_t *event, size_t msecs, process_midi_ctx_t
/* convert msecs */
nframes = msecs * ctx->sample_rate / 1000;
-// ok let's try this
-// hmm still nothing, well only thing left is ui, but i have doubt about that. i guess need to start from original jalv, and keep moving new parts of code there til it breaks, looks like it still has something that amsynth needs
-//another option might be keeping jalv code as original as possible, only thing we change is jack callback, so it would still need running jack, but intead of jack process callback we will call own callback which send events manually and get output. (maybe calling jacK_process_cb once to get atom send once).
-//
-//how does this work? well need to construct it same way as jalv did, then send it
- /* Get Jack transport position */
+//TODO maybe just get rid of this stuff
//ORIGINAL-> sending to evbuf: frame: 13136896, rolling: 1.000000, calc: -1, bar: 0, beat_type: 1146875112, bpb: 1184130760, bpm: 0: need valid if: -787014688
const bool rolling = 1;
@@ -160,19 +156,6 @@ int process_midi_cb(fluid_midi_event_t *event, size_t msecs, process_midi_ctx_t
lv2_atom_forge_long(forge, 13136896);
lv2_atom_forge_key(forge, jalv->urids.time_speed);
lv2_atom_forge_float(forge, rolling ? 1.0 : 0.0);
-/*if (pos.valid & JackPositionBBT) {
- lv2_atom_forge_key(forge, jalv->urids.time_barBeat);
- lv2_atom_forge_float(
- forge, pos.beat - 1 + (pos.tick / pos.ticks_per_beat));
- lv2_atom_forge_key(forge, jalv->urids.time_bar);
- lv2_atom_forge_long(forge, pos.bar - 1);
- lv2_atom_forge_key(forge, jalv->urids.time_beatUnit);
- lv2_atom_forge_int(forge, pos.beat_type);
- lv2_atom_forge_key(forge, jalv->urids.time_beatsPerBar);
- lv2_atom_forge_float(forge, pos.beats_per_bar);
- lv2_atom_forge_key(forge, jalv->urids.time_beatsPerMinute);
- lv2_atom_forge_float(forge, pos.beats_per_minute);
- }*/
if (jalv->opts.dump) {
char* str = sratom_to_turtle(
@@ -188,12 +171,6 @@ int process_midi_cb(fluid_midi_event_t *event, size_t msecs, process_midi_ctx_t
jalv->bpm = 120.0; //pos.beats_per_minute;
jalv->rolling = rolling;
-//
-//should we run this now? not yet, not sure yet what to do with bpm and frame
-//where do we send it? here
-//and when was lst time it worked, before changes here, or after too? still works, just with a different plugin (the other one we were testing). no changes really
-// except that loop that tests for which audio ports are output ports, and taking streams from them. but the thing is, it seems like no audio is coming out of the plugin
-//
/* Prepare port buffers */
for (uint32_t p = 0; p < jalv->num_ports; ++p) {
@@ -208,8 +185,10 @@ int process_midi_cb(fluid_midi_event_t *event, size_t msecs, process_midi_ctx_t
pluginAudioPtrs[pluginAudioOutputCount] = pluginAudioIOBuffers[p];
pluginAudioOutputCount++;
- printf("pluginAudioOutputCount: %d\n", pluginAudioOutputCount);
- printf("buffer %x ptr: %8x\n", p, pluginAudioIOBuffers[p]);
+ if(DEBUG){
+ printf("pluginAudioOutputCount: %d\n", pluginAudioOutputCount);
+ printf("buffer %x ptr: %8x\n", p, pluginAudioIOBuffers[p]);
+ }
}
} else if (port->type == TYPE_EVENT && port->flow == FLOW_INPUT) {
lv2_evbuf_reset(port->evbuf, true);
@@ -253,8 +232,6 @@ int process_midi_cb(fluid_midi_event_t *event, size_t msecs, process_midi_ctx_t
/* First, write all the obvious channels */
/* If outs > nchannels, we *could* do mixing - but don't. */
//actually you need another for loop in here for 10 channel wavs
-// sf_output[i * nchannels + 0] = pluginAudioIOBuffers[3][i];
-// sf_output[i * nchannels + 1] = pluginAudioIOBuffers[4][i];
for (size_t n = 0; n < pluginAudioOutputCount; n++){
sf_output[i * nchannels + n] = pluginAudioPtrs[n][i];
}
@@ -404,10 +381,6 @@ create_port(Jalv* jalv,
} else if (!optional) {
die("Mandatory port has unknown type (neither input nor output)");
}
-//ORIGINALjalv.sample_rate: 48000
-//we should add these? yeah
-//ORIGINALjalv.block_length: 1024
-//ORIGINALjalv midi_buf_size: 8000
/* Set control values */
if (lilv_port_is_a(jalv->plugin, port->lilv_port, jalv->nodes.lv2_ControlPort)) {
@@ -596,12 +569,10 @@ main(int argc, char** argv)
memset(&jalv, '\0', sizeof(Jalv));
jalv.prog_name = argv[0];
- jalv.block_length = 1024; //doesn't look like we use this though, right? looks so FIXME try removing
- jalv.midi_buf_size = 0x8000; //should I try running it? not yet
- //jalv.midi_buf_size = 1024;
+ jalv.block_length = 1024; //FIXME try removing
+ jalv.midi_buf_size = 0x8000;
jalv.play_state = JALV_PAUSED;
- //FIXME pass bpm
- jalv.bpm = 120.0f; //oh probably we don't even use this bpm, right? coul dbe
+ jalv.bpm = 120.0f; //TODO experiment with this
if (jalv_init(&argc, &argv, &jalv.opts)) {
@@ -616,6 +587,10 @@ main(int argc, char** argv)
jalv.opts.outfile = (char *)malloc(256);//
strcpy(jalv.opts.outfile, "output.wav");
}
+ if(!jalv.opts.infile){
+ jalv.opts.infile = (char *)malloc(256);//
+ strcpy(jalv.opts.infile, "test.mid");
+ }
if (! jalv.opts.sample_rate){
jalv.opts.sample_rate = 48000;
@@ -839,11 +814,8 @@ main(int argc, char** argv)
/* Create thread and ringbuffers for worker if necessary */
if (lilv_plugin_has_feature(jalv.plugin, jalv.nodes.work_schedule) // can we check if amsynth has this work_schedule feature? hmm yeah we should check via LV2-render, right? yeah
&& lilv_plugin_has_extension_data(jalv.plugin, jalv.nodes.work_interface)) {
-// jalv_worker_init(
- // &jalv, &jalv.worker,
- // (const LV2_Worker_Interface*)lilv_instance_get_extension_data(
- // jalv.instance, LV2_WORKER__interface));
- printf("NEED WORKER!\n"); //extension data test too? yeah I guess not ok let's see what else
+ printf("NEEDS TO USE A WORKER!\n");
+ exit(1);
}
ext_data.data_access = lilv_instance_get_descriptor(jalv.instance)->extension_data;
@@ -873,7 +845,6 @@ main(int argc, char** argv)
lilv_instance_activate(jalv.instance);
-//FIXME get sample rate from above...right? yes
jalv.sample_rate = jalv.opts.sample_rate;
jalv.play_state = JALV_RUNNING;
@@ -887,10 +858,7 @@ main(int argc, char** argv)
process_midi_ctx.outfile = outfile;
process_midi_ctx.sample_rate = sample_rate;
- load_midi_file("short_example.mid", (read_midi_callback)process_midi_cb, &process_midi_ctx);
-//
-//STUDY LATER
-
+ load_midi_file(jalv.opts.infile, (read_midi_callback)process_midi_cb, &process_midi_ctx);
sf_close(outfile);
diff --git a/src/LV2-render_console.c b/src/LV2-render_console.c
index 90e5c4a..b255037 100644
--- a/src/LV2-render_console.c
+++ b/src/LV2-render_console.c
@@ -17,9 +17,10 @@ print_usage(const char* name, bool error)
fprintf(os, "Usage: %s [OPTION...] PLUGIN_URI\n", name);
fprintf(os, "Render a midi file with an LV2 plugin instrument.\n");
fprintf(os, " -h Display this help and exit\n");
+ fprintf(os, " -i STRING filename for midi input (DEFAULT=test.mid)\n");
+ fprintf(os, " -o STRING filename for wavfile output (DEFAULT=output.wav)\n");
fprintf(os, " -p Print control output changes to stdout\n");
fprintf(os, " -c SYM=VAL Set control value (e.g. \"vol=1.4\")\n");
- fprintf(os, " -F STRING filename for wavfile output (DEFAULT=output.wav)\n");
fprintf(os, " -C NUM Integer number of channels for output, e.g. 2 (DEFAULT=2)\n");
fprintf(os, " -S NUM Integer sample rate of output, e.g. 44100 (DEFAULT=48000)\n");
fprintf(os, " -l DIR Load state from save directory\n");
@@ -76,12 +77,18 @@ jalv_init(int* argc, char*** argv, JalvOptions* opts)
return 1;
}
opts->sample_rate = atoi((*argv)[a]);
- } else if ((*argv)[a][1] == 'F') {
+ } else if ((*argv)[a][1] == 'i') {
if (++a == *argc) {
- fprintf(stderr, "Missing argument for -F\n");
+ fprintf(stderr, "Missing argument for -i\n");
return 1;
}
- opts->outfile = (*argv)[a]; //is this wrong? not really
+ opts->infile = (*argv)[a];
+ } else if ((*argv)[a][1] == 'o') {
+ if (++a == *argc) {
+ fprintf(stderr, "Missing argument for -o\n");
+ return 1;
+ }
+ opts->outfile = (*argv)[a];
} else if ((*argv)[a][1] == 'd') {
opts->dump = true;
} else {
diff --git a/src/LV2-render_internal.h b/src/LV2-render_internal.h
index 92be2f9..3cea889 100644
--- a/src/LV2-render_internal.h
+++ b/src/LV2-render_internal.h
@@ -83,6 +83,7 @@ typedef struct {
int nchannels; ///
int sample_rate; ///
char* outfile; //
+ char* infile; //
} JalvOptions;
typedef struct {
diff --git a/src/midi/NOTES b/src/midi/NOTES
deleted file mode 100644
index 4bd7b67..0000000
--- a/src/midi/NOTES
+++ /dev/null
@@ -1,84 +0,0 @@
-
- //unsigned long nevents; weird...so the plugin must know about previous notes that are pressed? yes for each call run_synth it should know about note which are currently pressed. oh but there isn't any place to indicate that? seems like we just need
- //to keep track of how many notes are currently running and pass it an unsigned long that has that count, but aside from that,
- //it just takes note_on and note_off structs, which refer to only one note at a time? not really,
- //so in C to pass an array we have to use two variables onw is a pointer to data, another is number of elements in that array. so run_synth is one of such functions, and if you have two notes pressed you send array of size 2, storing two elements nearby in memory and setting nevents to 2. got it, so current_event isn't a pointer to a struct, it's a pointer to an array of event structs, most likely? yes
-//
-//so what do we do next? we need to construct this array of currently pressed notes, so need to check events and try to construc this.
-
-
-
-
-//ok moving on...I did a bit of research about midi types...basically the reason mrswatson only supports type0 midi is that
-//the idea behind type0 midi is that it is single-channel. Here channel is a bit of a confusing word, because there is also such a thing as an audio channel, obviously
-//but the two are completely unrelated. Channel is like a track in multitrack recording, type0 midi only has one of these tracks, but potentially has program
-//changes within it (program change is just a change of voice). so what we're working on here only handles single channel midi as well, and that's good.
-//Only thing to think about is, if we abstract our loop to process the note events in the channel, rather than the note events in the entire file (unfortunately confusing
-//terminology again, because in midifiles, the entire file is called a "track"). But this is basically the situation.
-//
-//Midi events come in a few different types, but basically there are three types that are important
-//
-//meta type events
-//
-//channel events (events particular to a single channel)
-//
-//track events (events that apply to every channel)
-//
-//so meta type events are sort of special events,
-//
-//channel events and track events are more like "regular" events....
-//
-//do you follow so far? yep
-//
-//
-//
-//So the main question to ask you is, since we are iterating through all events, how do we handle multiple channels? we have the option to do what mrswatson has done
-//which is to read the midi file type from the header and end in error if it is anything but type0, or we can sort of process the channels individually in the sense that we send appropriate info to the plugin, telling it which channel it is intended for. Most plugins though don't care about multiple channels
-//
-//another option, more related to the first is to write a simple script (or find one) that separates out multi-channel midi into individual type0 files.
-//
-//so with multi channel files, if events are sorted by time in file, then we can just send them all at once as it was one channel, so plugin will produce resulting file.
-//if that's the plan, I guess we should check to make sure that dssi doesn't support multiple channels, because if it does, maybe we should tell the plugin which channel each event is intended for? i think snd_seq_event_t has that filed for channel, so we just need to copy that info there.
-//
-//
-//
-//ok do we break now? seems a bit late yeah, so basically what is left to do is to write it from pseudo code to real code of this function, add pritngin to see how it works and if there is any bugs to fix them.
-//ok then make this into a module, add it to cli-dssi-host and change cli-dssi-host source to deal with this loop? yep. got it. maybe we can look into this tomorrow morning? sure ok perfect
-
-
-
- //ok so what were you thinking here?
- //ok and finally that run_synth need array which is not sparse, where elements are without spaces, so either you rebuild
- //new array every time you call run_synth, or keep elements together and use find function to locate a note. find function
- //sounds best, either way, do we need two arrays? no need
-
- //with this, can I assign sparsely to it, if I want to put the notes[100] = 4; , will that cause an error?
- //so first is that you need to put size of memory you use in malloc, not e lemtns, like that, right? yep
- //second is that we need snd_seq_event_t intead of ints. I was just thinking that if the note is pressed, it wouldn
- //have a value , if not it wouldn't so it would be an easy way to keep track of which are pressed or not? hmm sort of short lookup arraly, might work if built properly. ok well I don't know if that's right I'll make another array
-//question is, if we're sending a list, and a NOTE_ON and NOTE_OFF must be removed from the list once it has been already processed, how do we access those elements? by note name somehow? yeah need to track each note on\off pair.
-//no clue how to do this in C, easy in any other language, just use an associative array
-//right in C it turns into function which finds an element in array. how big should our array be? do we use the heap here? ideally we need to use it, but guess we can limit number of notes which are pressed at same time, like 100 or so should be plently there are only so many midi notes, I'll get the count 128 that should be the limit good, try write with heap functions, might be useful to see how to work with it. well could I just
-
-
-
-
- //so what does this return exactly? so then event arrives we need to try find note if it was pressed or not.
- //so basically whole logic of get_events function is:
- //
- //snd_seq_event_t event = convert_event(fluid_midi_event_t);
- //event_in_table = find_event(&event);
- //switch(event->type ){
- // case NOTE_ON:
- // if(event_in_table) return; // skip if pressed while still was pressed, shouldn't happen...I think it just gets pressed again, but both are deleted on the note_off, does that make sense? hmm might be, but that change a logic a bit
- // yeah something like this. so basic idea is clear or not really? yeah it's clear, just too advanced for me
- // to come up with on my own right now given my current skills with C, it's coming along fast though well it's simple then written in perl or somethng else, just showing how c does the same things. so now need to implement those functions ok
- // insert_event(event);
- // run_synth();
- //
- // case NOTE_OFF:
- // replace_events(event_in_table,event)
- // run_synth()
- // delete_events(event);
- //
- //}
diff --git a/src/midi/example.mid b/src/midi/example.mid
deleted file mode 100644
index 328d6ef..0000000
--- a/src/midi/example.mid
+++ /dev/null
Binary files differ
diff --git a/src/midi/example1.mid b/src/midi/example1.mid
deleted file mode 100644
index 2fa1b91..0000000
--- a/src/midi/example1.mid
+++ /dev/null
Binary files differ
diff --git a/src/midi/example2.mid b/src/midi/example2.mid
deleted file mode 100644
index bf3bfc0..0000000
--- a/src/midi/example2.mid
+++ /dev/null
Binary files differ
diff --git a/src/midi/fluid_midi.c b/src/midi/fluid_midi.c
index 062ba3c..618aca3 100644
--- a/src/midi/fluid_midi.c
+++ b/src/midi/fluid_midi.c
@@ -1,10 +1,7 @@
#include "fluid_midi.h"
#include <math.h>
-//#include "fluid_sys.h"
-//#include "fluid_synth.h"
-//#include "fluid_settings.h"
-
+#define DEBUG 0
int
fluid_log(int level, const char* fmt, ...)
{
@@ -62,7 +59,6 @@ new_fluid_midi_file(const char* buffer, size_t length)
}
return mf;
}
-//ok how do you usually create a file_pointer in this case? with fopen FILE READ do you think we can just try this function directly with fopen? yes, fluid_file i think is just FILE * returned by fopen, so code will be fopen, fluid_file_read_full and then new_fluid_midi_file.
static char*
fluid_file_read_full(fluid_file fp, size_t* length)
@@ -213,7 +209,6 @@ int fluid_midi_file_eof(fluid_midi_file* mf)
/*
* fluid_midi_file_read_mthd
*/
-//it's actually does all the work inside new_fluid_midi_file function to read file and get all events allocated and set, so now we just need to print those.
int
fluid_midi_file_read_mthd(fluid_midi_file *mf)
{
@@ -238,7 +233,7 @@ fluid_midi_file_read_mthd(fluid_midi_file *mf)
return FLUID_FAILED;
} else {
mf->uses_smpte = 0;
- mf->division = (mthd[12] << 8) | (mthd[13] & 0xff); //division is in the header for the midi file, he gets the value here. do we have access to it in custom.c? looks like player have also current time in milliseconds too, in addition to ticks, we can try to just use those. ok good. so the player is doing the parsing, we're just
+ mf->division = (mthd[12] << 8) | (mthd[13] & 0xff);
FLUID_LOG(FLUID_DBG, "Division=%d", mf->division);
}
@@ -421,7 +416,6 @@ fluid_midi_file_read_varlen(fluid_midi_file *mf)
/*
* fluid_midi_file_read_event
*/
-//could be this, right...it only takes the file and the track as args
int
fluid_midi_file_read_event(fluid_midi_file *mf, fluid_track_t *track)
{
@@ -760,7 +754,7 @@ fluid_midi_file_get_division(fluid_midi_file *midifile)
*/
/**
- * MIDI EVENT DEFINED HERE...do we need to figure out exactly how this ties in to cli-dssi-host next? not yet, for now we need working midi loading from file and listing events according to each time sample. should we write a print event function? yeah in main() custom.c
+ * MIDI EVENT DEFINED HERE
* Create a MIDI event structure.
* @return New MIDI event structure or NULL when out of memory.
*/
@@ -1183,7 +1177,7 @@ fluid_track_reset(fluid_track_t *track)
*/
int
fluid_track_send_events(fluid_track_t *track,
- fluid_synth_t *synth, //will the null pointer cause an error here? nope, will work //doesn't use it? here... I guess not
+ fluid_synth_t *synth,
fluid_player_t *player,
unsigned int ticks)
{
@@ -1197,10 +1191,6 @@ fluid_track_send_events(fluid_track_t *track,
return status;
}
-//ok it should be printing here, right? well need to check flow again, starting from load_tracks if it reach this function or not
-//do we decide now to just listen for note on and note off, and keep track of the two? yep
-//run_synth also takes velocity, so maybe we should add that as well? i guess so
-
if (track->ticks + event->dtime > ticks) {
return status;
}
@@ -1233,7 +1223,6 @@ fluid_track_send_events(fluid_track_t *track,
* @param synth fluid synthesizer instance to create player for
* @return New MIDI player instance or NULL on error (out of memory)
*/
-//ok how do we call new_fluid_player with the filename of the midifile? wmayeb call fluid_player_load() with file name
fluid_player_t *
new_fluid_player(void)
{
@@ -1261,7 +1250,6 @@ new_fluid_player(void)
player->deltatime = 4.0;
player->cur_msec = 0;
player->cur_ticks = 0;
- // FIXME fluid_player_set_playback_callback(player, fluid_synth_handle_midi_event, synth);
// player->use_system_timer = fluid_settings_str_equal(synth->settings,
// "player.timing-source", "system");
@@ -1335,9 +1323,6 @@ fluid_player_reset(fluid_player_t *player)
player->track[i] = NULL;
}
}
- /* player->current_file = NULL; */
- /* player->status = FLUID_PLAYER_READY; */
- /* player->loop = 1; */
player->ntracks = 0;
player->division = 0;
player->send_program_change = 1;
@@ -1465,8 +1450,9 @@ fluid_player_add_mem(fluid_player_t* player, const void *buffer, size_t len)
int
fluid_player_load(fluid_player_t *player, fluid_playlist_item *item)
{
- puts("inside fluid player load");
- //ok do you think this is the function we need to check? well i found it, this long printf i uncommented wasn't used, we need to use fluid_track_send_events inside loop over loaded tracks to actually send events into our callback. ok
+ if (DEBUG){
+ puts("inside fluid player load");
+ }
fluid_midi_file *midifile;
char* buffer;
size_t buffer_length;
@@ -1502,7 +1488,6 @@ fluid_player_load(fluid_player_t *player, fluid_playlist_item *item)
/* Do not free the buffer (it is owned by the playlist) */
buffer_owned = 0;
}
-// here file
midifile = new_fluid_midi_file(buffer, buffer_length);
if (midifile == NULL) {
if (buffer_owned) {
@@ -1514,7 +1499,6 @@ fluid_player_load(fluid_player_t *player, fluid_playlist_item *item)
//DIVISION SET HERE
fluid_player_set_midi_tempo(player, player->miditempo); // Update deltatime
/*FLUID_LOG(FLUID_DBG, "quarter note division=%d\n", player->division); */
-// here it load tracks
if (fluid_midi_file_load_tracks(midifile, player) != FLUID_OK) {
if (buffer_owned) {
FLUID_FREE(buffer);
@@ -1574,10 +1558,6 @@ fluid_player_playlist_load(fluid_player_t *player, unsigned int msec)
player->start_ticks = 0;
player->cur_ticks = 0;
-// if (player->reset_synth_between_songs) {
-// fluid_synth_system_reset(player->synth);
-// }
-
for (i = 0; i < player->ntracks; i++) {
if (player->track[i] != NULL) {
fluid_track_reset(player->track[i]);
@@ -1589,8 +1569,6 @@ fluid_player_playlist_load(fluid_player_t *player, unsigned int msec)
/*
* fluid_player_callback
*/
-//ok so I guess it all starts here? not sure, new_fluid_player starts a new player struct, then we need fluid_player_load(player, playlist_item)
-//and playlist_item have filename of file to load got it
int
fluid_player_callback(void *data, unsigned int msec)
{
@@ -1733,8 +1711,6 @@ int fluid_player_set_loop(fluid_player_t *player, int loop)
int fluid_player_set_midi_tempo(fluid_player_t *player, int tempo)
{
player->miditempo = tempo;
- //DIVISION CALCULATION MADE HERE
- //USE THIS TO FIX MRS WATSON
player->deltatime = (double) tempo / player->division / 1000.0; /* in milliseconds */
player->start_msec = player->cur_msec;
player->start_ticks = player->cur_ticks;
diff --git a/src/midi/fluid_midi.h b/src/midi/fluid_midi.h
index 608ba55..af83873 100644
--- a/src/midi/fluid_midi.h
+++ b/src/midi/fluid_midi.h
@@ -22,8 +22,6 @@
#define _FLUID_MIDI_H
#include "fluidsynth_priv.h"
-//#include "fluid_sys.h"
-//#include "custom.h"
#include "fluid_list.h"
#include <stdlib.h>
#include <stdio.h>
@@ -322,13 +320,10 @@ fluid_track_t* fluid_player_get_track(fluid_player_t* player, int i);
int fluid_player_reset(fluid_player_t* player);
int fluid_player_load(fluid_player_t* player, fluid_playlist_item *item);
-//void fluid_player_settings(fluid_settings_t* settings);
-
/*
* fluid_midi_file
*/
-//hmm no events though here, right? looks so
typedef struct {
const char* buffer; /* Entire contents of MIDI file (borrowed) */
int buf_len; /* Length of buffer, in bytes */
diff --git a/src/midi/midi_loader.c b/src/midi/midi_loader.c
index 2cdd539..98cfe21 100644
--- a/src/midi/midi_loader.c
+++ b/src/midi/midi_loader.c
@@ -1,9 +1,12 @@
#include "midi_loader.h"
+#define DEBUG 0
//static int event_count = 0;
size_t last_msec = 0;
size_t nmsecs_since_last = 0;
+
+
void print_event(fluid_midi_event_t *event, size_t current_msec){
// {{{ DESCRIPTION
// fluid_midi_event_t* next; /* Link to next event */
@@ -14,14 +17,15 @@ void print_event(fluid_midi_event_t *event, size_t current_msec){
// unsigned char type; /* MIDI event type */
// unsigned char channel; /* MIDI channel */
//}}}
-// printf("EVENT_COUNT: %d\n", event_count);
- printf("dtime:%u ", event->dtime);
- printf("param1:%u ", event->param1);
- printf("param2: %u ", event->param2);
- printf("type: %x ", event->type);
- printf("channel: %u ", event->channel);
- printf("nframe: %u ", current_msec);
- puts("\n");
+ if(DEBUG){
+ printf("dtime:%u ", event->dtime);
+ printf("param1:%u ", event->param1);
+ printf("param2: %u ", event->param2);
+ printf("type: %x ", event->type);
+ printf("channel: %u ", event->channel);
+ printf("nframe: %u ", current_msec);
+ puts("\n");
+ }
}
int get_events(void *data, fluid_midi_event_t *event){
@@ -32,16 +36,12 @@ int get_events(void *data, fluid_midi_event_t *event){
read_midi_callback cb = ctx->callback;
size_t current_msec;
-// event_count++;
current_msec = (player->deltatime * track->ticks);
nmsecs_since_last = current_msec - last_msec;
last_msec = current_msec;
-// print_event(event, current_msec);
//process_midi_cb execution...
- cb(event, nmsecs_since_last, ctx->callback_userdata); // seems good, check the output ok
-//ok I'm going to study this, make a git back it up clean it up etc tomorrow, but I think I understand. this is
-//definitely coming along. thanks so much for the help no problems alright awesome, I'll talk to you and send you a payment again soon thanks again
+ cb(event, nmsecs_since_last, ctx->callback_userdata);
}
void load_midi_file(char *filename, read_midi_callback callback, void *callback_userdata){
diff --git a/src/midi/midi_loader.h b/src/midi/midi_loader.h
index 57cee25..5b901d6 100644
--- a/src/midi/midi_loader.h
+++ b/src/midi/midi_loader.h
@@ -2,13 +2,12 @@
#define MIDI_LOADER_H
#include "fluid_list.h"
-#include "fluidsynth_priv.h" //is this the right idea? just need to load libs in the right order? yep
+#include "fluidsynth_priv.h"
#include "fluid_midi.h"
#include <sndfile.h>
#include <string.h>
#include <ladspa.h>
#include <dssi.h>
-//load all of those in the same way as below? or is the problem with how fluid_midi is accessing this file? yeah basically order issue
typedef struct event_table_t{
@@ -18,11 +17,8 @@ typedef struct event_table_t{
size_t nframes_since_last;
} event_table_t;
-//typedef void(*read_midi_callback)(event_table_t *event_table, void *userdata);
typedef void(*read_midi_callback)(fluid_midi_event_t *event, size_t msecs_since_last, void *userdata);
-
-
typedef struct read_midi_ctx_t {
fluid_player_t *player;
fluid_track_t *track;
@@ -30,17 +26,6 @@ typedef struct read_midi_ctx_t {
void *callback_userdata;
} read_midi_ctx_t;
-
-//void insert_event(event_table_t *event_table, snd_seq_event_t *event){
-//void delete_event(event_table_t *event_table, snd_seq_event_t *event){
-//int compare_events(snd_seq_event_t *event1, snd_seq_event_t *event2){
-//void replace_events(event_table_t *event_table, snd_seq_event_t *event){
-//like this?
-//void convert_event_format(fluid_midi_event_t *from, snd_seq_event_t *to);
-//void print_snd_seq_event(snd_seq_event_t *event);
-//void print_event_table (event_table_t *event_table);
-//int get_events(void *data, fluid_midi_event_t *event);
-
void print_snd_seq_event(snd_seq_event_t *event);
void load_midi_file(char *filename, read_midi_callback callback, void *callback_userdata);
#endif
diff --git a/src/midi/midi_loader_test.c b/src/midi/midi_loader_test.c
index d79392d..4ed7d39 100644
--- a/src/midi/midi_loader_test.c
+++ b/src/midi/midi_loader_test.c
@@ -178,7 +178,7 @@ int get_events(void *data, fluid_midi_event_t *event){
snd_seq_event_t seq_event;
size_t last_nframe = event_table->last_nframe;
- event_table->last_nframe = (player->deltatime * track->ticks) * 44100 / 1000; // FIXME 44100 to ctx->samplerate
+ event_table->last_nframe = (player->deltatime * track->ticks) * 44100 / 1000;
event_table->nframes_since_last = event_table->last_nframe - last_nframe;
convert_event_format(event, &seq_event);