diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt index c0a746335..e1bf0c2ec 100644 --- a/docs/CHANGES.txt +++ b/docs/CHANGES.txt @@ -65,7 +65,12 @@ https://tuxpaint.org/ available, each with differing pen positions. + Code: Bill Kendrick + WIP - Needs icons - + WIP - Needs sounds + + WIP Sounds: + - Drag: TBD + - Epitrochoid draw "celtic_harp_c3.wav" & + Hypotrochoid draw "celtic_harp_c2.wav" + both CC0 1.0 Universal + by Daphne Farazi (https://soundcloud.com/daphnefarazi) * Improvements to "Text" & "Label" tools: --------------------------------------- diff --git a/magic/sounds/epitrochoid.ogg b/magic/sounds/epitrochoid.ogg new file mode 100644 index 000000000..ced6fa04b Binary files /dev/null and b/magic/sounds/epitrochoid.ogg differ diff --git a/magic/sounds/hypotrochoid.ogg b/magic/sounds/hypotrochoid.ogg new file mode 100644 index 000000000..3e4f9a6d8 Binary files /dev/null and b/magic/sounds/hypotrochoid.ogg differ diff --git a/magic/src/trochoids.c b/magic/src/trochoids.c index 217ed4132..568bec87e 100644 --- a/magic/src/trochoids.c +++ b/magic/src/trochoids.c @@ -133,7 +133,8 @@ const char *tool_descriptions[NUM_TOOLS] = { /* Sound effects (same for everyone) */ enum { SND_DRAW_CLICK, - SND_DRAW_RELEASE, + SND_DRAW_RELEASE_EPITROCHOID, + SND_DRAW_RELEASE_HYPOTROCHOID, NUM_SNDS }; @@ -141,7 +142,8 @@ Mix_Chunk *sound_effects[NUM_SNDS]; const char *sound_filenames[NUM_SNDS] = { "n_pt_persp_click.ogg", // FIXME - "n_pt_persp_release.ogg", // FIXME + "epitrochoid.ogg", + "hypotrochoid.ogg", }; Uint8 trochoids_size = 1; @@ -424,11 +426,51 @@ void trochoids_release(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect) { + int tool, snd_idx, R, vol, pan; + + /* If they clicked & released with no drag, + ignore the (x,y) we received; we want the + 'default' offset to get a reasonably pleasant + shape -- for users who tried clicking w/o dragging */ if (dragged == 0) { x += (canvas->w / 20); y += (canvas->h / 20); } + /* Pick which sound to play */ + tool = which_to_tool[which]; + if (tool == TOOL_EPITROCHOID_SIZES || + tool == TOOL_EPITROCHOID_NOSIZES_1 || + tool == TOOL_EPITROCHOID_NOSIZES_2 || + tool == TOOL_EPITROCHOID_NOSIZES_3) { + snd_idx = SND_DRAW_RELEASE_EPITROCHOID; + } else { + snd_idx = SND_DRAW_RELEASE_HYPOTROCHOID; + } + + /* Volume based on the radius of the stator (fixed circle); + larger = louder */ + R = abs(trochoids_x - x); + if (R < 20) { + R = 20; + } else if (R > canvas->w) { + R = canvas->w; + } + vol = (255 * R * 2) / canvas->w; + if (vol > 255) { + vol = 255; + } + + /* (Stop previous sound if they made another shape quickly; + the sound effect lingers & we want to start playing again, + else it will seem like the sound only happens intermittently) */ + api->stopsound(); + + /* Panning based on the left/right position of the shape */ + pan = 128; /* FIXME */ + api->playsound(sound_effects[snd_idx], pan, vol); + + /* Draw it (no guides, this time!) */ trochoids_work(api, which, canvas, snapshot, x, y, update_rect, 0); }