-
Notifications
You must be signed in to change notification settings - Fork 0
/
libtimidity-0.2.4-patch.diff
112 lines (106 loc) · 3.49 KB
/
libtimidity-0.2.4-patch.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
diff -u -r libtimidity-0.2.4/src/instrum.c libtimidity/src/instrum.c
--- libtimidity-0.2.4/src/instrum.c 2016-12-05 15:50:00.000000000 +0000
+++ libtimidity/src/instrum.c 2017-05-24 03:29:53.000000000 +0100
@@ -203,6 +203,20 @@
if (song->ifp == NULL)
{
DEBUG_MSG("Instrument `%s' can't be found.\n", name);
+
+ /* Add this to the log */
+ if (!song->load_request_buffer)
+ song->load_request_buffer = timi_calloc(128 * sizeof(char *));
+
+ if (song->load_request_count < 128) {
+ /* Make sure we haven't already added it */
+ for (i=0; i < song->load_request_count; i++)
+ if (!strcmp(song->load_request_buffer[i], name))
+ return;
+
+ song->load_request_buffer[song->load_request_count++] = strdup(name);
+ }
+
return;
}
fp = song->ifp;
diff -u -r libtimidity-0.2.4/src/timidity.c libtimidity/src/timidity.c
--- libtimidity-0.2.4/src/timidity.c 2017-03-18 14:40:00.000000000 +0000
+++ libtimidity/src/timidity.c 2017-05-24 03:25:55.000000000 +0100
@@ -639,6 +639,12 @@
timi_free(song->meta_data[i]);
}
+ if (song->load_request_buffer) {
+ for (i = 0; i < song->load_request_count; i++)
+ timi_free(song->load_request_buffer[i]);
+ timi_free(song->load_request_buffer);
+ }
+
timi_free(song);
}
@@ -704,3 +710,25 @@
return NULL;
}
+
+/* For JavaScript -> libTiMidity compatibility */
+extern MidSongOptions *mid_alloc_options(sint32 rate, uint16 format, uint8 channels, uint16 buffer_size)
+{
+ MidSongOptions *o = (MidSongOptions *) timi_calloc(sizeof(MidSongOptions));
+ o->rate = rate;
+ o->format = format;
+ o->channels = channels;
+ o->buffer_size = buffer_size;
+ return o;
+}
+
+extern int mid_get_load_request_count(MidSong *song)
+{
+ return song->load_request_count;
+}
+
+extern char *mid_get_load_request(MidSong *song, int index)
+{
+ return song->load_request_buffer[index];
+}
+
diff -u -r libtimidity-0.2.4/src/timidity.h libtimidity/src/timidity.h
--- libtimidity-0.2.4/src/timidity.h 2017-03-18 20:55:50.000000000 +0000
+++ libtimidity/src/timidity.h 2017-05-24 02:59:23.000000000 +0100
@@ -217,6 +217,30 @@
TIMI_EXPORT extern void mid_dlspatches_free (MidDLSPatches *data);
+/* JavaScript Binding Helper Functions
+ * ===================================
+ */
+
+/* Create a MidSongOptions instance on the heap.
+ * The caller is responsible for freeing it using free() later.
+ */
+ TIMI_EXPORT extern MidSongOptions *mid_alloc_options (sint32 rate,
+ uint16 format,
+ uint8 channels,
+ uint16 buffer_size);
+
+/* Return the amount of patch files that the song requires.
+ */
+ TIMI_EXPORT extern int mid_get_load_request_count (MidSong *song);
+
+
+/* Return the name of a patch file that the song requires.
+ */
+ TIMI_EXPORT extern char *mid_get_load_request (MidSong *song,
+ int index);
+
+
+
/* MIDI Song Functions
* ===================
*/
diff -u -r libtimidity-0.2.4/src/timidity_internal.h libtimidity/src/timidity_internal.h
--- libtimidity-0.2.4/src/timidity_internal.h 2017-02-21 20:33:50.000000000 +0000
+++ libtimidity/src/timidity_internal.h 2017-05-24 02:44:07.000000000 +0100
@@ -257,6 +257,8 @@
sint32 at;
sint32 groomed_event_count;
char *meta_data[MID_META_MAX];
+ int load_request_count;
+ char **load_request_buffer;
};
#endif /* TIMIDITY_INTERNAL_H */