diff --git a/assets/music/main_theme.wav b/assets/music/main_theme.wav index cce8552..115ae3f 100644 Binary files a/assets/music/main_theme.wav and b/assets/music/main_theme.wav differ diff --git a/assets/music/main_theme.wav.import b/assets/music/main_theme.wav.import new file mode 100644 index 0000000..a9e41ac --- /dev/null +++ b/assets/music/main_theme.wav.import @@ -0,0 +1,21 @@ +[remap] + +importer="wav" +type="AudioStreamSample" +path="res://.import/main_theme.wav-fc7a93fb910535b9bc6e7800904a7ba5.sample" + +[deps] + +source_file="res://assets/music/main_theme.wav" +dest_files=[ "res://.import/main_theme.wav-fc7a93fb910535b9bc6e7800904a7ba5.sample" ] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop=false +compress/mode=0 diff --git a/assets/source/music/src/music/songs/main_theme.clj b/assets/source/music/src/music/songs/main_theme.clj index d168597..1838c4c 100644 --- a/assets/source/music/src/music/songs/main_theme.clj +++ b/assets/source/music/src/music/songs/main_theme.clj @@ -1,75 +1,16 @@ -(ns music.songs.main-theme - (:require - [clojure.set :as set] - [edna.core :as edna])) +(ns music.songs.main-theme) (def tempo 72) (defn intro [volume] - #{ - [:piano {:octave 4 - :tempo tempo - :volume volume} - 1/4 :-d :-a 1/8 :-e :-c 1/4 :-g :e :c - 1/2 :-d - 1/4 :-d :-a 1/8 :-e :-c 1/4 :-g :d :-f 1/8 :e :g 1/4 :f :a 1/16 :g 1/4 :f 1/2 :c] }) - -(defn verse [volume] - #{ - [:piano {:octave 4 - :tempo tempo - :volume volume} - 1/16 #{:-d :f#} 1/8 #{:-e :+f} :a 1/2 #{:f# :+d} - :r :r - 1/16 #{:-c :g#} 1/8 #{:-e :+f} :b 1/2 #{:+d :f#}] - [:steel-drum {:octave 3 - :tempo tempo - :volume (quot volume 2) } - 1/8 :-a :a :b 1/2 :a - :c :c - :a 1/8 :b :a :-a] - [:acoustic-bass {:octave 3 - :tempo tempo - :volume (quot volume 3) } - 1/8 :-a :a :b 1/2 :a - :c :c - :a 1/8 :b :a :-a]}) - -(defn pre-chorus [volume] - #{ - [:steel-drum {:octave 3 - :tempo (* 2 tempo) - :volume volume} - 1/8 :a 1/4 :a 1/8 :b 1/2 :-a] - [:acoustic-bass {:octave 3 - :tempo (* 2 tempo) - :volume volume} - 1/8 :b 1/4 :c 1/8 :g 1/2 :-g#] - }) - -(defn chorus [volume] - #{ - [:piano {:octave 3 - :tempo tempo - :volume volume} - 1/16 #{:-d :f#} 1/8 #{:-e :+f} :a 1/4 #{:f# :+d} - 1/16 :c :r :d :r :e :r :f - 1/16 :r 1/4 :d 1/8 :r :r - 1/16 :f :r :e :r :d :r :c ] - [:acoustic-bass {:octave 3 - :tempo tempo - :volume (quot volume 3) } - 1/16 :-a :a :b :c 1/4 :a - 1/64 (repeat 7 [:c :d :g :-f]) - 1/16 :a :c :b :a 1/4 :-b - 1/64 (repeat 7 [:-b :a :c :-g])] }) + (set + (map + (fn [instrument] [instrument {:octave 2 + :tempo tempo + :volume volume} + 1/4 :-d :-a 1/8 :-e :-c 1/4 :-g :e :c + 1/2 :-d + 1/4 :-d :-a 1/8 :-e :-c 1/4 :-g :d :-f 1/8 :e :g 1/4 :f :a 1/16 :g 1/4 :f 1/2 :c]) [:piano :violin :acoustic-bass]))) (concat - (map intro [20 40 80 100]) - (map verse [100 80]) - (map pre-chorus [60 80]) - (map verse [100]) - (map pre-chorus [60 80]) - (map chorus [100 100]) - (map verse [100 60]) - (map chorus [40 20])) + (map intro [70 100])) diff --git a/menu/main_menu.gd b/menu/main_menu.gd index d13eaf1..6cd66f4 100644 --- a/menu/main_menu.gd +++ b/menu/main_menu.gd @@ -4,6 +4,7 @@ extends Panel func _ready() -> void: # gdlint: ignore=max-line-length $MarginContainer/VSplitContainer/VSplitContainer/CenterContainer/VBoxContainer/StartButton.grab_focus() + MusicPlayer.play_theme("main") func _on_StartButton_pressed() -> void: diff --git a/music/MusicPlayer.gd b/music/MusicPlayer.gd new file mode 100644 index 0000000..df04cdd --- /dev/null +++ b/music/MusicPlayer.gd @@ -0,0 +1,12 @@ +extends Node + +export var main_theme: AudioStream + +onready var themes = {"main": main_theme} + +onready var player: AudioStreamPlayer = $Player + + +func play_theme(theme: String) -> void: + player.stream = themes[theme] + player.play() diff --git a/music/MusicPlayer.tscn b/music/MusicPlayer.tscn new file mode 100644 index 0000000..7ab31e5 --- /dev/null +++ b/music/MusicPlayer.tscn @@ -0,0 +1,13 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://music/MusicPlayer.gd" type="Script" id=1] +[ext_resource path="res://assets/music/main_theme.wav" type="AudioStream" id=2] + +[node name="Node" type="Node"] +script = ExtResource( 1 ) +main_theme = ExtResource( 2 ) + +[node name="Player" type="AudioStreamPlayer" parent="."] +stream = ExtResource( 2 ) +autoplay = true +bus = "Music" diff --git a/project.godot b/project.godot index 11a9d65..029e84e 100644 --- a/project.godot +++ b/project.godot @@ -46,6 +46,7 @@ config/icon="res://icon.png" [autoload] GlobalSettings="*res://settings/GlobalSettings.gd" +MusicPlayer="*res://music/MusicPlayer.tscn" [editor_plugins]