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 22050
41 #define PD_SAMPLES_PER_HZ ((PD_SAMPLERATE / HZ) + \
42 (PD_SAMPLERATE % HZ > 0 ? 1 : 0))
43 #define PD_OUT_CHANNELS 2
45 /* Audio buffer part. Contains data for one HZ period. */
47 #define AUDIOBUFSIZE (PD_SAMPLES_PER_HZ * PD_OUT_CHANNELS * 4)
49 #define AUDIOBUFSIZE (PD_SAMPLES_PER_HZ * PD_OUT_CHANNELS)
53 int16_t data
[AUDIOBUFSIZE
];
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 strncmp rb->strncmp
143 #define atoi rb->atoi
144 #define write rb->write
146 #define strncat rb_strncat
147 #define floor rb_floor
150 #define ftoan rb_ftoan
153 #define log10 rb_log10
160 #define atan2 rb_atan2