10 #define NUM_CHANNELS 8 65 buttonRect.
x = spacing;
66 buttonRect.
y = spacing;
67 buttonRect.
w = renderW - 2 * spacing;
78 buttonRect.
y += spacing + buttonRect.
h;
98 mixer.outputSpec.format,
99 mixer.outputSpec.channels,
100 mixer.outputSpec.freq);
103 }
else if (result != 0) {
125 int x,
y, mouseIndex,
i, drumIndex;
141 if (drumIndex != -1) {
143 buttons[drumIndex].touchIndex = mouseIndex;
144 buttons[drumIndex].isPressed = 1;
194 int selected_channel = -1;
195 int oldest_channel = 0;
197 if (
mixer.numSoundsPlaying == 0) {
204 if (
mixer.channels[i].position ==
NULL) {
206 selected_channel =
i;
210 if (
mixer.channels[i].timestamp <
211 mixer.channels[oldest_channel].timestamp)
216 if (selected_channel == -1)
217 selected_channel = oldest_channel;
219 mixer.numSoundsPlaying++;
222 mixer.channels[selected_channel].position = s->
buffer;
223 mixer.channels[selected_channel].remaining = s->
length;
226 return selected_channel;
241 if (
mixer.channels[i].position ==
NULL) {
248 mixer.channels[
i].remaining <
256 mixer.channels[
i].position += copy_amt;
257 mixer.channels[
i].remaining -= copy_amt;
260 if (
mixer.channels[i].remaining == 0) {
262 mixer.numSoundsPlaying--;
263 if (
mixer.numSoundsPlaying == 0) {
294 mixer.outputSpec.freq = 44100;
296 mixer.outputSpec.channels = 2;
297 mixer.outputSpec.samples = 256;
319 switch (event.
type) {
#define SDL_MIX_MAXVOLUME
GLint GLint GLint GLint GLint x
void fatalError(const char *string)
#define SDL_BuildAudioCVT
#define SDL_RenderFillRect
void loadSound(const char *file, struct sound *s)
#define SDL_MixAudioFormat
int main(int argc, char *argv[])
GLint GLint GLsizei width
A structure to hold a set of audio conversion filters and buffers.
#define SDL_GetWindowSize
void initializeButtons(SDL_Renderer *)
int playSound(struct sound *)
Uint32 SDL_GetTicks(void)
Get the number of milliseconds since the SDL library initialization.
static SDL_Renderer * renderer
#define SDL_RenderSetLogicalSize
void handleMouseButtonUp(SDL_Event *event)
static struct sound drums[NUM_DRUMS]
#define SDL_LoadWAV(file, spec, audio_buf, audio_len)
GLint GLint GLint GLint GLint GLint y
void audioCallback(void *userdata, Uint8 *stream, int len)
void handleMouseButtonDown(SDL_Event *event)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
GLint GLint GLsizei GLsizei height
EGLSurface EGLNativeWindowType * window
The type used to identify a window.
#define SDL_SetRenderDrawColor
void render(SDL_Renderer *renderer)
static struct @63 buttons[NUM_DRUMS]
#define SDL_RenderGetLogicalSize
#define SDL_GetMouseState
#define SDL_CreateRenderer
A rectangle, with the origin at the upper left.
#define SDL_RenderPresent
struct @64::@65 channels[NUM_CHANNELS]