1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2009 Wincent Balin
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
33 /* dbestfit declarations. */
35 /* Minimal memory size. */
36 #define MIN_MEM_SIZE (4 * 1024 * 1024)
39 /* Audio declarations. */
40 #define PD_SAMPLERATE 32000
41 #define PD_SAMPLES_QUOT (PD_SAMPLERATE / HZ)
42 #define PD_SAMPLES_REM (PD_SAMPLERATE % HZ)
43 #if PD_SAMPLES_REM == 0
44 #define PD_SAMPLES_PER_HZ (PD_SAMPLES_QUOT)
46 #define PD_SAMPLES_PER_HZ (PD_SAMPLES_QUOT + 1)
49 /* Audio data types. */
50 #define PD_AUDIO_BLOCK_SIZE PD_SAMPLES_PER_HZ
51 struct pdbox_audio_block
54 int32_t data
[PD_AUDIO_BLOCK_SIZE
];
58 /* Additional functions. */
59 char *rb_strncat(char *s
, const char *t
, size_t n
);
60 double rb_strtod(const char*, char**);
61 double rb_atof(const char*);
62 void rb_ftoan(float, char*, int);
63 float rb_floor(float);
64 long rb_atol(const char* s
);
65 float rb_sin(float rad
);
66 float rb_cos(float rad
);
67 int rb_fscanf_f(int fd
, float* f
);
68 int rb_fprintf_f(int fd
, float f
);
69 float rb_log10(float);
72 float rb_pow(float, float);
76 float rb_atan2(float, float);
85 div_t div(int x
, int y
);
86 void sys_findlibdir(const char* filename
);
87 int sys_startgui(const char *guidir
);
90 /* Network declarations. */
92 /* Maximal size of the datagram. */
93 #define MAX_DATAGRAM_SIZE 255
95 /* This structure replaces a UDP datagram. */
100 char data
[MAX_DATAGRAM_SIZE
];
103 /* Prototypes of network functions. */
105 void net_destroy(void);
106 bool send_datagram(struct event_queue
* route
, int port
,
107 char* data
, size_t size
);
108 bool receive_datagram(struct event_queue
* route
, int port
,
109 struct datagram
* buffer
);
111 /* Network message queues. */
112 extern struct event_queue gui_to_core
;
113 extern struct event_queue core_to_gui
;
115 /* UDP ports of the original software. */
116 #define PD_CORE_PORT 3333
117 #define PD_GUI_PORT 3334
119 /* Convinience macros. */
120 #define SEND_TO_CORE(data) \
121 send_datagram(&gui_to_core, PD_CORE_PORT, data, strlen(data))
122 #define RECEIVE_TO_CORE(buffer) \
123 receive_datagram(&gui_to_core, PD_CORE_PORT, buffer)
124 #define SEND_FROM_CORE(data) \
125 send_datagram(&core_to_gui, PD_GUI_PORT, data, strlen(data))
126 #define RECEIVE_FROM_CORE(buffer) \
127 receive_datagram(&core_to_gui, PD_GUI_PORT, buffer)
129 /* PD core message callback. */
130 void rockbox_receive_callback(struct datagram
* dg
);
133 /* Pure Data declarations. */
135 /* Pure Data function prototypes. */
139 /* Redefinitons of ANSI C functions. */
140 #include "lib/wrappers.h"
142 #define strncat rb_strncat
143 #define floor rb_floor
146 #define ftoan rb_ftoan
149 #define log10 rb_log10
156 #define atan2 rb_atan2