diff options
| author | _Tradam <[email protected]> | 2021-12-16 19:22:26 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-12-16 19:22:26 -0500 |
| commit | 5954b9beb4d4a3b4f248d72d1851195f030558a8 (patch) | |
| tree | fecd8aa840a25afdb502915b0fdb4d03b7ed339a /samples/01_rendering_basics/06_audio_mixer | |
| parent | 2f845281f133849256b57bb08fd3e9ae57600784 (diff) | |
| parent | eaa29e72939f5edf61735ccbb73c36ee89369f65 (diff) | |
| download | dragonruby-game-toolkit-contrib-master.tar.gz dragonruby-game-toolkit-contrib-master.zip | |
Diffstat (limited to 'samples/01_rendering_basics/06_audio_mixer')
| -rw-r--r-- | samples/01_rendering_basics/06_audio_mixer/app/main.rb | 160 | ||||
| -rw-r--r-- | samples/01_rendering_basics/06_audio_mixer/license-for-audio.txt | 48 | ||||
| -rw-r--r-- | samples/01_rendering_basics/06_audio_mixer/license-for-sample.txt | 9 | ||||
| -rw-r--r-- | samples/01_rendering_basics/06_audio_mixer/sounds/1.wav | bin | 409170 -> 0 bytes | |||
| -rw-r--r-- | samples/01_rendering_basics/06_audio_mixer/sounds/2.wav | bin | 22374 -> 0 bytes | |||
| -rw-r--r-- | samples/01_rendering_basics/06_audio_mixer/sounds/3.wav | bin | 420476 -> 0 bytes | |||
| -rw-r--r-- | samples/01_rendering_basics/06_audio_mixer/sounds/4.wav | bin | 91358 -> 0 bytes | |||
| -rw-r--r-- | samples/01_rendering_basics/06_audio_mixer/sounds/5.wav | bin | 117354 -> 0 bytes | |||
| -rw-r--r-- | samples/01_rendering_basics/06_audio_mixer/sounds/6.ogg | bin | 330572 -> 0 bytes |
9 files changed, 0 insertions, 217 deletions
diff --git a/samples/01_rendering_basics/06_audio_mixer/app/main.rb b/samples/01_rendering_basics/06_audio_mixer/app/main.rb deleted file mode 100644 index ce48d3f..0000000 --- a/samples/01_rendering_basics/06_audio_mixer/app/main.rb +++ /dev/null @@ -1,160 +0,0 @@ -$gtk.reset - -$boxsize = 30 - -def render_sources args - mouse_in_panel = (args.state.selected != 0) && args.inputs.mouse.position.inside_rect?([900, 450, 340, 250]) - mouse_new_down = (args.state.mouse_held == 1) - - if (mouse_new_down && !mouse_in_panel) - args.state.selected = 0 # will reset below if we hit something. - end - - args.audio.keys.each { |k| - s = args.audio[k] - - if (mouse_new_down) && !mouse_in_panel && args.inputs.mouse.position.inside_rect?([s[:screenx], s[:screeny], $boxsize, $boxsize]) - args.state.selected = k - args.state.dragging_source = true - end - - isselected = (k == args.state.selected) - - if isselected && args.state.dragging_source - # you can hang anything on the audio hashes you want, so we store the - # actual screen position so it doesn't scale weirdly vs your mouse. - s[:screenx] = args.inputs.mouse.x - ($boxsize / 2) - s[:screeny] = args.inputs.mouse.y - ($boxsize / 2) - - s[:screeny] = 50 if s[:screeny] < 50 - s[:screeny] = (719 - $boxsize) if s[:screeny] > (719 - $boxsize) - s[:screenx] = 0 if s[:screenx] < 0 - s[:screenx] = (1279 - $boxsize) if s[:screenx] > (1279 - $boxsize) - - s[:x] = ((s[:screenx] / 1279.0) * 2.0) - 1.0 # scale to -1.0 - 1.0 range - s[:y] = ((s[:screeny] / 719.0) * 2.0) - 1.0 # scale to -1.0 - 1.0 range - end - - color = isselected ? [ 0, 255, 0, 255 ] : [ 0, 0, 255, 255 ] - args.outputs.primitives << [s[:screenx], s[:screeny], $boxsize, $boxsize, *color].solid - } -end - -def render_panel args - s = args.audio[args.state.selected] - return if s.nil? - mouse_down = (args.state.mouse_held > 0) - - args.outputs.primitives << [900, 450, 340, 250, 127, 127, 200, 255].solid - args.outputs.primitives << [1075, 690, "Source ##{args.state.selected}", 3, 1, 255, 255, 255].label - args.outputs.primitives << [910, 660, 1230, 660, 255, 255, 255].line - args.outputs.primitives << [910, 650, "screen: (#{s[:screenx].to_i}, #{s[:screeny].to_i})", 0, 0, 255, 255, 255].label - args.outputs.primitives << [910, 625, "position: (#{s[:x].round(5).to_s[0..6]}, #{s[:y].round(5).to_s[0..6]})", 0, 0, 255, 255, 255].label - - slider = [1022, 586, 200, 7] - if mouse_down && args.inputs.mouse.position.inside_rect?(slider) - s[:pitch] = ((args.inputs.mouse.x - slider[0]).to_f / (slider[2]-1.0)) * 2.0 - end - slidercolor = (s[:pitch] / 2.0) * 255 - args.outputs.primitives << [*slider, slidercolor, slidercolor, slidercolor, 255].solid - args.outputs.primitives << [910, 600, "pitch: #{s[:pitch].round(3).to_s[0..2]}", 0, 0, 255, 255, 255].label - - slider = [1022, 561, 200, 7] - if mouse_down && args.inputs.mouse.position.inside_rect?(slider) - s[:gain] = (args.inputs.mouse.x - slider[0]).to_f / (slider[2]-1.0) - end - slidercolor = s[:gain] * 255 - args.outputs.primitives << [*slider, slidercolor, slidercolor, slidercolor, 255].solid - args.outputs.primitives << [910, 575, "gain: #{s[:gain].round(3).to_s[0..2]}", 0, 0, 255, 255, 255].label - - checkbox = [1022, 533, 10, 12] - if (args.state.mouse_held == 1) && args.inputs.mouse.position.inside_rect?(checkbox) - s[:looping] = !s[:looping] - end - checkboxcolor = s[:looping] ? 255 : 0 - args.outputs.primitives << [*checkbox, checkboxcolor, checkboxcolor, checkboxcolor, 255].solid - args.outputs.primitives << [910, 550, "looping:", 0, 0, 255, 255, 255].label - - checkbox = [1022, 508, 10, 12] - if (args.state.mouse_held == 1) && args.inputs.mouse.position.inside_rect?(checkbox) - s[:paused] = !s[:paused] - end - checkboxcolor = s[:paused] ? 255 : 0 - args.outputs.primitives << [*checkbox, checkboxcolor, checkboxcolor, checkboxcolor, 255].solid - args.outputs.primitives << [910, 525, "paused:", 0, 0, 255, 255, 255].label - - button = [910, 460, 320, 20] - if (args.state.mouse_held == 1) && args.inputs.mouse.position.inside_rect?(button) - args.audio.delete(args.state.selected) - args.state.selected = 0 - end - args.outputs.primitives << [*button, 255, 0, 0, 255].solid - args.outputs.primitives << [button[0] + (button[2] / 2), button[1]+20, "DELETE SOURCE", 0, 1, 255, 255, 0].label -end - -def spawn_new_sound args, num - input = nil - input = "sounds/#{num}.#{(num == 6) ? 'ogg' : 'wav'}" - - # Spawn randomly in an area that won't be covered by UI. - screenx = (rand * 600.0) + 200.0 - screeny = (rand * 400.0) + 100.0 - - args.state.next_sound_index += 1 - - # you can hang anything on the audio hashes you want, so we store the - # actual screen position in here for convenience. - args.audio[args.state.next_sound_index] = { - input: input, - screenx: screenx, - screeny: screeny, - x: ((screenx / 1279.0) * 2.0) - 1.0, # scale to -1.0 - 1.0 range - y: ((screeny / 719.0) * 2.0) - 1.0, # scale to -1.0 - 1.0 range - z: 0.0, - gain: 1.0, - pitch: 1.0, - looping: true, - paused: false - } - - args.state.selected = args.state.next_sound_index -end - -def render_launcher args - total = 6 - x = (1280 - (total * $boxsize * 3)) / 2 - y = 10 - args.outputs.primitives << [0, 0, 1280, ((y*2) + $boxsize), 127, 127, 127, 255].solid - for i in 1..total - args.outputs.primitives << [x, y, $boxsize, $boxsize, 255, 255, 255, 255].solid - args.outputs.primitives << [x+8, y+28, i.to_s, 3, 0, 0, 0, 255, 255].label - if args.inputs.mouse.click && args.inputs.mouse.click.point.inside_rect?([x, y, $boxsize, $boxsize]) - spawn_new_sound args, i - end - x = x + ($boxsize * 3) - end -end - -def render_ui args - render_launcher args - render_panel args -end - -def tick args - args.state.mouse_held ||= 0 - args.state.dragging_source ||= false - args.state.selected ||= 0 - args.state.next_sound_index ||= 0 - - if args.inputs.mouse.up - args.state.mouse_held = 0 - args.state.dragging_source = false - elsif args.inputs.mouse.down || (args.state.mouse_held > 0) - args.state.mouse_held += 1 - else - end - - args.outputs.background_color = [ 0, 0, 0, 255 ] - render_sources args - render_ui args -end diff --git a/samples/01_rendering_basics/06_audio_mixer/license-for-audio.txt b/samples/01_rendering_basics/06_audio_mixer/license-for-audio.txt deleted file mode 100644 index f05c25c..0000000 --- a/samples/01_rendering_basics/06_audio_mixer/license-for-audio.txt +++ /dev/null @@ -1,48 +0,0 @@ -The audio files in this sample are used under various Creative Common licenses: - - -sounds/1.wav: - - Party Pack, Horn Coil 01, Long, 01.wav by InspectorJ (www.jshaw.co.uk) of Freesound.org - (We converted this to mono output.) - Original: https://freesound.org/s/484267/ - License: https://creativecommons.org/licenses/by/3.0/ - - -sounds/2.wav: - - SPLASH.wav by petenice - Original: https://freesound.org/s/9508/ - License: https://creativecommons.org/publicdomain/zero/1.0/ - - -sounds/3.wav: - - buzz roll.wav by bigjoedrummer - (We converted this to mono output.) - Original: https://freesound.org/s/77305/ - License: https://creativecommons.org/publicdomain/zero/1.0/ - - -sounds/4.wav: - - sword04.wav by Erdie - Original: https://freesound.org/s/27858/ - License: https://creativecommons.org/licenses/by/3.0/ - - -sounds/5.wav: - - Game Over Arcade.wav by myfox14 - (We converted this to mono output.) - Original: https://freesound.org/s/382310/ - License: https://creativecommons.org/publicdomain/zero/1.0/ - - -sounds/6.ogg: - - Arcade Music Loop.wav by joshuaempyre ( https://www.empyreanma.com/welcome ) - (We converted this to Ogg Vorbis format, and mono output.) - Original: https://freesound.org/s/251461/ - License: https://creativecommons.org/licenses/by/3.0/ - diff --git a/samples/01_rendering_basics/06_audio_mixer/license-for-sample.txt b/samples/01_rendering_basics/06_audio_mixer/license-for-sample.txt deleted file mode 100644 index 100dcec..0000000 --- a/samples/01_rendering_basics/06_audio_mixer/license-for-sample.txt +++ /dev/null @@ -1,9 +0,0 @@ -Copyright 2019 DragonRuby LLC - -MIT License - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/samples/01_rendering_basics/06_audio_mixer/sounds/1.wav b/samples/01_rendering_basics/06_audio_mixer/sounds/1.wav Binary files differdeleted file mode 100644 index 8aa1be3..0000000 --- a/samples/01_rendering_basics/06_audio_mixer/sounds/1.wav +++ /dev/null diff --git a/samples/01_rendering_basics/06_audio_mixer/sounds/2.wav b/samples/01_rendering_basics/06_audio_mixer/sounds/2.wav Binary files differdeleted file mode 100644 index 52a09c2..0000000 --- a/samples/01_rendering_basics/06_audio_mixer/sounds/2.wav +++ /dev/null diff --git a/samples/01_rendering_basics/06_audio_mixer/sounds/3.wav b/samples/01_rendering_basics/06_audio_mixer/sounds/3.wav Binary files differdeleted file mode 100644 index c7bde27..0000000 --- a/samples/01_rendering_basics/06_audio_mixer/sounds/3.wav +++ /dev/null diff --git a/samples/01_rendering_basics/06_audio_mixer/sounds/4.wav b/samples/01_rendering_basics/06_audio_mixer/sounds/4.wav Binary files differdeleted file mode 100644 index 193cf54..0000000 --- a/samples/01_rendering_basics/06_audio_mixer/sounds/4.wav +++ /dev/null diff --git a/samples/01_rendering_basics/06_audio_mixer/sounds/5.wav b/samples/01_rendering_basics/06_audio_mixer/sounds/5.wav Binary files differdeleted file mode 100644 index 112f3cc..0000000 --- a/samples/01_rendering_basics/06_audio_mixer/sounds/5.wav +++ /dev/null diff --git a/samples/01_rendering_basics/06_audio_mixer/sounds/6.ogg b/samples/01_rendering_basics/06_audio_mixer/sounds/6.ogg Binary files differdeleted file mode 100644 index a952191..0000000 --- a/samples/01_rendering_basics/06_audio_mixer/sounds/6.ogg +++ /dev/null |
