summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/plugins/pdbox/SOURCES166
-rw-r--r--apps/plugins/pdbox/pdbox-net.c118
-rw-r--r--apps/plugins/pdbox/pdbox.c156
-rw-r--r--apps/plugins/pdbox/pdbox.h1
-rw-r--r--apps/plugins/pdbox/pdbox.make30
5 files changed, 3 insertions, 468 deletions
diff --git a/apps/plugins/pdbox/SOURCES b/apps/plugins/pdbox/SOURCES
index 8c6db8ade3..0eb24e1311 100644
--- a/apps/plugins/pdbox/SOURCES
+++ b/apps/plugins/pdbox/SOURCES
@@ -89,172 +89,9 @@ PDa/src/x_gui.c
89/* 89/*
90PDa/src/d_imayer_fft.c 90PDa/src/d_imayer_fft.c
91*/ 91*/
92PDa/src/m_fixed.c
93
94/*
95PDa/intern/biquad~.c
96PDa/intern/bp~.c
97PDa/intern/clip~.c
98PDa/intern/cos~.c
99PDa/intern/dbtopow~.c
100PDa/intern/dbtorms~.c
101PDa/intern/delread~.c
102PDa/intern/delwrite~.c
103PDa/intern/env~.c
104PDa/intern/ftom~.c
105PDa/intern/hip~.c
106PDa/intern/intern_setup.c
107PDa/intern/line~.c
108PDa/intern/lop~.c
109PDa/intern/mtof~.c
110PDa/intern/noise~.c
111PDa/intern/osc~.c
112PDa/intern/phasor~.c
113PDa/intern/powtodb~.c
114PDa/intern/print~.c
115PDa/intern/rmstodb~.c
116PDa/intern/rsqrt~.c
117PDa/intern/samphold~.c
118*/
119/* PDa/intern/sfread~.c Does not compile, file handling stuff */
120/* PDa/intern/sfwrite~.c Does not compile, file handling stuff */
121/*
122PDa/intern/sig~.c
123PDa/intern/snapshot~.c
124PDa/intern/sqrt~.c
125PDa/intern/tabosc4~.c
126PDa/intern/tabplay~.c
127PDa/intern/tabread.c
128PDa/intern/tabread4~.c
129PDa/intern/tabread~.c
130PDa/intern/tabreceive~.c
131PDa/intern/tabsend~.c
132PDa/intern/tabwrite.c
133PDa/intern/tabwrite~.c
134PDa/intern/threshold~.c
135PDa/intern/vcf~.c
136PDa/intern/vd~.c
137PDa/intern/vline~.c
138PDa/intern/vsnapshot~.c
139PDa/intern/wrap~.c
140*/
141
142/*
143PDa/extra/OSCroute.c
144PDa/extra/bandpass.c
145*/
146/* PDa/extra/dumpOSC.c Does not compile, file handling stuff */
147/*
148PDa/extra/equalizer.c
149PDa/extra/gcanvas.c
150PDa/extra/highpass.c
151PDa/extra/highshelf.c
152PDa/extra/hlshelf.c
153PDa/extra/image.c
154PDa/extra/lowpass.c
155PDa/extra/lowshelf.c
156PDa/extra/moog~.c
157PDa/extra/notch.c
158*/
159/* PDa/extra/sendOSC.c Does not compile, file handling stuff */
160/*
161PDa/extra/shell.c
162PDa/extra/slider.c
163PDa/extra/sliderh.c
164PDa/extra/zerox~.c
165*/
166pdbox.c
167pdbox-net.c
168
169/*
170dbestfit-3.3/bmalloc.c
171dbestfit-3.3/bysize.c
172dbestfit-3.3/dmalloc.c
173*/
174
175/* 92/*
176PDa/src/g_canvas.c
177PDa/src/g_graph.c
178PDa/src/g_text.c
179*/
180/* PDa/src/g_rtext.c Does not compile */
181/*
182PDa/src/g_array.c
183PDa/src/g_template.c
184PDa/src/g_io.c
185PDa/src/g_scalar.c
186PDa/src/g_traversal.c
187PDa/src/g_guiconnect.c
188PDa/src/g_readwrite.c
189PDa/src/g_editor.c
190PDa/src/g_all_guis.c
191PDa/src/g_bang.c
192PDa/src/g_hdial.c
193PDa/src/g_hslider.c
194PDa/src/g_mycanvas.c
195PDa/src/g_numbox.c
196PDa/src/g_toggle.c
197PDa/src/g_vdial.c
198PDa/src/g_vslider.c
199PDa/src/g_vumeter.c
200PDa/src/m_pd.c
201PDa/src/m_class.c
202PDa/src/m_obj.c
203PDa/src/m_atom.c
204*/
205/*
206PDa/src/m_memory.c
207*/
208
209/* PDa/src/m_binbuf.c Does not compile, file handling stuff */
210/*
211PDa/src/m_conf.c
212PDa/src/m_glob.c
213PDa/src/m_sched.c
214*/
215/* PDa/src/s_main.c Does not compile, system reasons */
216/* PDa/src/s_inter.c Does not compile, BSD sockets */
217/* PDa/src/s_file.c Does not compile, file handling stuff */
218/* PDa/src/s_print.c Does not compile, system reasons */
219/*
220PDa/src/s_loader.c
221*/
222/* PDa/src/s_path.c Does not compile, file handling stuff */
223/*
224PDa/src/s_entry.c
225PDa/src/s_audio.c
226PDa/src/s_midi.c
227PDa/src/d_ugen.c
228PDa/src/d_arithmetic.c
229PDa/src/d_dac.c
230PDa/src/d_misc.c
231PDa/src/d_fft.c
232PDa/src/d_mayer_fft.c
233PDa/src/d_fftroutine.c
234PDa/src/d_global.c
235PDa/src/d_resample.c
236PDa/src/d_ctl.c
237*/
238/* PDa/src/d_soundfile.c Does not compile, file handling stuff */
239/*
240PDa/src/x_arithmetic.c
241PDa/src/x_connective.c
242PDa/src/x_interface.c
243PDa/src/x_midi.c
244PDa/src/x_misc.c
245PDa/src/x_time.c
246PDa/src/x_acoustics.c
247*/
248/* PDa/src/x_net.c Does not compile, BSD sockets */
249/*
250PDa/src/x_qlist.c
251PDa/src/x_gui.c
252*/
253
254/*
255PDa/src/d_imayer_fft.c
256*/
257PDa/src/m_fixed.c 93PDa/src/m_fixed.c
94*/
258 95
259/* 96/*
260PDa/intern/biquad~.c 97PDa/intern/biquad~.c
@@ -328,3 +165,4 @@ PDa/extra/slider.c
328PDa/extra/sliderh.c 165PDa/extra/sliderh.c
329PDa/extra/zerox~.c 166PDa/extra/zerox~.c
330*/ 167*/
168
diff --git a/apps/plugins/pdbox/pdbox-net.c b/apps/plugins/pdbox/pdbox-net.c
index 5767226de3..83d9bd3b7d 100644
--- a/apps/plugins/pdbox/pdbox-net.c
+++ b/apps/plugins/pdbox/pdbox-net.c
@@ -117,122 +117,4 @@ void net_destroy(void)
117 rb->queue_delete(&gui_to_core); 117 rb->queue_delete(&gui_to_core);
118 rb->queue_delete(&core_to_gui); 118 rb->queue_delete(&core_to_gui);
119} 119}
120/***************************************************************************
121 * __________ __ ___.
122 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
123 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
124 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
125 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
126 * \/ \/ \/ \/ \/
127 * $Id$
128 *
129 * Copyright (C) 2009 Wincent Balin
130 *
131 * This program is free software; you can redistribute it and/or
132 * modify it under the terms of the GNU General Public License
133 * as published by the Free Software Foundation; either version 2
134 * of the License, or (at your option) any later version.
135 *
136 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
137 * KIND, either express or implied.
138 *
139 ****************************************************************************/
140
141#include "plugin.h"
142#include "pdbox.h"
143
144/* Datagram pool will contains 16 datagrams. */
145#define MAX_DATAGRAMS 16
146
147/* Datagram pool. */
148struct datagram datagrams[MAX_DATAGRAMS];
149
150/* UDP message queues. */
151struct event_queue gui_to_core;
152struct event_queue core_to_gui;
153
154/* Initialize net infrastructure. */
155void net_init(void)
156{
157 unsigned int i;
158
159 /* Initialize message pool. */
160 for(i = 0; i < MAX_DATAGRAMS; i++)
161 datagrams[i].used = false;
162
163 /* Initialize and register message queues. */
164 rb->queue_init(&gui_to_core, true);
165 rb->queue_init(&core_to_gui, true);
166}
167
168/* Send datagram. */
169bool send_datagram(struct event_queue* route,
170 int port,
171 char* data,
172 size_t size)
173{
174 unsigned int i;
175
176 /* If datagram too long, abort. */
177 if(size > MAX_DATAGRAM_SIZE)
178 return false;
179 120
180 /* Find free datagram buffer. */
181 for(i = 0; i < MAX_DATAGRAMS; i++)
182 if(!datagrams[i].used)
183 break;
184
185 /* If no free buffer found, abort. */
186 if(i == MAX_DATAGRAMS)
187 return false;
188
189 /* Copy datagram to the buffer. */
190 rb->memcpy(datagrams[i].data, data, size);
191 datagrams[i].size = size;
192
193 /* Mark datagram buffer as used. */
194 datagrams[i].used = true;
195
196 /* Send event via route. */
197 rb->queue_post(route, port, (intptr_t) &datagrams[i]);
198
199 /* Everything went ok. */
200 return true;
201}
202
203/* Receive datagram. */
204bool receive_datagram(struct event_queue* route,
205 int port,
206 struct datagram* buffer)
207{
208 struct queue_event event;
209
210 /* If route queue empty, abort. */
211 if(rb->queue_empty(route))
212 return false;
213
214 /* Receive event. */
215 rb->queue_wait(route, &event);
216
217 /* If wrong port, abort.
218 NOTE: Event is removed from the queue in any case! */
219 if(event.id != port)
220 return false;
221
222 /* Copy datagram. */
223 rb->memcpy(buffer, (struct datagram*) event.data, sizeof(struct datagram));
224
225 /* Free datagram buffer. */
226 ((struct datagram*) event.data)->used = false;
227
228 /* Everything went ok. */
229 return true;
230}
231
232/* Destroy net infrastructure. */
233void net_destroy(void)
234{
235 /* Remove message queues. */
236 rb->queue_delete(&gui_to_core);
237 rb->queue_delete(&core_to_gui);
238}
diff --git a/apps/plugins/pdbox/pdbox.c b/apps/plugins/pdbox/pdbox.c
index 9407849352..c3fb4499e1 100644
--- a/apps/plugins/pdbox/pdbox.c
+++ b/apps/plugins/pdbox/pdbox.c
@@ -155,160 +155,4 @@ enum plugin_status plugin_start(const void* parameter)
155 155
156 return PLUGIN_OK; 156 return PLUGIN_OK;
157} 157}
158/***************************************************************************
159 * __________ __ ___.
160 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
161 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
162 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
163 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
164 * \/ \/ \/ \/ \/
165 * $Id$
166 *
167 * Copyright (C) 2009 Wincent Balin
168 *
169 * This program is free software; you can redistribute it and/or
170 * modify it under the terms of the GNU General Public License
171 * as published by the Free Software Foundation; either version 2
172 * of the License, or (at your option) any later version.
173 *
174 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
175 * KIND, either express or implied.
176 *
177 ****************************************************************************/
178
179#include "plugin.h"
180#include "pdbox.h"
181
182/* Welcome to the PDBox plugin */
183PLUGIN_HEADER
184PLUGIN_IRAM_DECLARE
185
186/* Quit flag. */
187bool quit = false;
188
189/* Thread IDs. */
190unsigned int core_thread_id;
191unsigned int gui_thread_id;
192
193/* Stacks for threads. */
194#define STACK_SIZE 16384
195uint32_t core_stack[STACK_SIZE / sizeof(uint32_t)];
196uint32_t gui_stack[STACK_SIZE / sizeof(uint32_t)];
197
198
199/* Core thread */
200void core_thread(void)
201{
202 struct datagram ping;
203
204 /* Main loop */
205 while(!quit)
206 {
207 /* Wait for request. */
208 while(!RECEIVE_TO_CORE(&ping))
209 rb->yield();
210
211 if(memcmp("Ping!", ping.data, ping.size) == 0)
212 {
213 SEND_FROM_CORE("Pong!");
214 break;
215 }
216
217 rb->yield();
218 }
219
220 rb->thread_exit();
221}
222
223/* GUI thread */
224void gui_thread(void)
225{
226 struct datagram pong;
227
228 /* GUI loop */
229 while(!quit)
230 {
231 /* Send ping to the core. */
232 SEND_TO_CORE("Ping!");
233 rb->splash(HZ, "Sent ping.");
234
235 /* Wait for answer. */
236 while(!RECEIVE_FROM_CORE(&pong))
237 rb->yield();
238
239 /* If got a pong -- everything allright. */
240 if(memcmp("Pong!", pong.data, pong.size) == 0)
241 {
242 rb->splash(HZ, "Got pong!");
243 quit = true;
244 break;
245 }
246
247 rb->yield();
248 }
249
250 rb->thread_exit();
251}
252
253
254/* Plug-in entry point */
255enum plugin_status plugin_start(const void* parameter)
256{
257 PLUGIN_IRAM_INIT(rb)
258
259 size_t mem_size;
260 void* mem_pool;
261
262 /* Get the file name. */
263 const char* filename = (const char*) parameter;
264
265#if 0
266 /* Allocate memory; check it's size; add to the pool. */
267 mem_pool = rb->plugin_get_audio_buffer(&mem_size);
268 if(mem_size < MIN_MEM_SIZE)
269 {
270 rb->splash(HZ, "Not enough memory!");
271 return PLUGIN_ERROR;
272 }
273 add_pool(mem_pool, mem_size);
274#endif
275 158
276 /* Initialze net. */
277 net_init();
278
279 /* Start threads. */
280 core_thread_id =
281 rb->create_thread(&core_thread,
282 core_stack,
283 sizeof(core_stack),
284 0, /* FIXME Which flags? */
285 "PD core"
286 IF_PRIO(, MAX(PRIORITY_USER_INTERFACE / 2,
287 PRIORITY_REALTIME + 1))
288 IF_COP(, COP));
289 gui_thread_id =
290 rb->create_thread(&gui_thread,
291 gui_stack,
292 sizeof(gui_stack),
293 0, /* FIXME Which flags? */
294 "PD GUI"
295 IF_PRIO(, PRIORITY_USER_INTERFACE)
296 IF_COP(, CPU));
297
298 /* If having an error creating threads, bail out. */
299 if(core_thread_id == 0 || gui_thread_id == 0)
300 return PLUGIN_ERROR;
301
302 /* Wait for quit flag. */
303 while(!quit)
304 rb->yield();
305
306 /* Wait for threads to complete. */
307 rb->thread_wait(gui_thread_id);
308 rb->thread_wait(core_thread_id);
309
310 /* Destroy net. */
311 net_destroy();
312
313 return PLUGIN_OK;
314}
diff --git a/apps/plugins/pdbox/pdbox.h b/apps/plugins/pdbox/pdbox.h
index d5e9a0f74d..d8ddd96078 100644
--- a/apps/plugins/pdbox/pdbox.h
+++ b/apps/plugins/pdbox/pdbox.h
@@ -140,3 +140,4 @@ extern struct event_queue core_to_gui;
140 receive_datagram(&core_to_gui, PD_GUI_PORT, buffer) 140 receive_datagram(&core_to_gui, PD_GUI_PORT, buffer)
141 141
142#endif 142#endif
143
diff --git a/apps/plugins/pdbox/pdbox.make b/apps/plugins/pdbox/pdbox.make
index f1b1e7efef..bb10db417d 100644
--- a/apps/plugins/pdbox/pdbox.make
+++ b/apps/plugins/pdbox/pdbox.make
@@ -29,34 +29,4 @@ PDBOXFLAGS = $(PLUGINFLAGS) \
29$(PDBOXBUILDDIR)/%.o: $(PDBOXSRCDIR)/%.c $(PDBOXSRCDIR)/pdbox.make 29$(PDBOXBUILDDIR)/%.o: $(PDBOXSRCDIR)/%.c $(PDBOXSRCDIR)/pdbox.make
30 $(SILENT)mkdir -p $(dir $@) 30 $(SILENT)mkdir -p $(dir $@)
31 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(dir $<) $(PDBOXFLAGS) -c $< -o $@ 31 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(dir $<) $(PDBOXFLAGS) -c $< -o $@
32# __________ __ ___.
33# Open \______ \ ____ ____ | | _\_ |__ _______ ___
34# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
35# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
36# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
37# \/ \/ \/ \/ \/
38# $Id$
39#
40
41PDBOXSRCDIR := $(APPSDIR)/plugins/pdbox
42PDBOXBUILDDIR := $(BUILDDIR)/apps/plugins/pdbox
43
44ROCKS += $(PDBOXBUILDDIR)/pdbox.rock
45
46PDBOXSRC := $(call preprocess, $(PDBOXSRCDIR)/SOURCES)
47PDBOXOBJ := $(call c2obj, $(PDBOXSRC))
48
49# add source files to OTHERSRC to get automatic dependencies
50OTHERSRC += $(PDBOXSRC)
51 32
52$(PDBOXBUILDDIR)/pdbox.rock: $(PDBOXOBJ)
53
54PDBOXFLAGS = $(PLUGINFLAGS) \
55 -DFIXEDPOINT -DSTATIC -DPD \
56 -I$(PDBOXSRCDIR) -I$(PDBOXSRCDIR)/PDa/src \
57 -DBMALLOC -I$(PDBOXSRCDIR)/dbestfit-3.3
58
59# Compile PDBox with extra flags (adapted from ZXBox)
60$(PDBOXBUILDDIR)/%.o: $(PDBOXSRCDIR)/%.c $(PDBOXSRCDIR)/pdbox.make
61 $(SILENT)mkdir -p $(dir $@)
62 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(dir $<) $(PDBOXFLAGS) -c $< -o $@