Compare commits
7 Commits
main
...
soundtrack
Author | SHA1 | Date |
---|---|---|
Ensar Sarajčić | e4b432b22a | |
Ensar Sarajčić | 9cdfc17815 | |
Ensar Sarajčić | ed9d478d0c | |
Ensar Sarajčić | a7a44d26ae | |
Ensar Sarajčić | bea1d43a15 | |
Ensar Sarajčić | 8e70093fe6 | |
Ensar Sarajčić | 655dc82ef8 |
Binary file not shown.
|
@ -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=true
|
||||
edit/normalize=false
|
||||
edit/loop=true
|
||||
compress/mode=0
|
|
@ -0,0 +1,5 @@
|
|||
target/
|
||||
resources/
|
||||
!resources/public/index.html
|
||||
.*
|
||||
!.gitignore
|
|
@ -0,0 +1,30 @@
|
|||
# Bugged racing music source
|
||||
|
||||
Music for this game is builts using [edna](https://github.com/oakes/edna) clojure library, which uses [alda](https://github.com/alda-lang/alda) underneath.
|
||||
|
||||
To build this project, you'll need the Clojure CLI tool:
|
||||
|
||||
https://clojure.org/guides/deps_and_cli
|
||||
|
||||
To develop in a browser with live code reloading:
|
||||
|
||||
`clj -M dev.clj`
|
||||
|
||||
|
||||
To build a release version for the web:
|
||||
|
||||
`clj -M prod.clj`
|
||||
|
||||
|
||||
To play the song once:
|
||||
|
||||
`clj -M dev.clj play [song]`
|
||||
|
||||
|
||||
To build wav:
|
||||
|
||||
`clj -M prod.clj wav [song]`
|
||||
|
||||
To build wav for all songs:
|
||||
|
||||
`clj -M prod.clj soundtrack`
|
|
@ -0,0 +1,4 @@
|
|||
{:paths ["src" "resources"]
|
||||
:deps {org.clojure/clojurescript {:mvn/version "1.10.764"}
|
||||
com.bhauman/figwheel-main {:mvn/version "0.2.9"}
|
||||
edna/edna {:mvn/version "1.6.0"}}}
|
|
@ -0,0 +1,20 @@
|
|||
(defmulti task first)
|
||||
|
||||
(defmethod task :default
|
||||
[[task-name]]
|
||||
(println "Unknown task:" task-name)
|
||||
(System/exit 1))
|
||||
|
||||
(require '[figwheel.main :as figwheel])
|
||||
|
||||
(defmethod task nil
|
||||
[_]
|
||||
(figwheel/-main "--build" "dev"))
|
||||
|
||||
(require '[music.core])
|
||||
|
||||
(defmethod task "play"
|
||||
[_]
|
||||
(music.core/-main "main_theme"))
|
||||
|
||||
(task *command-line-args*)
|
|
@ -0,0 +1,5 @@
|
|||
{:main music.core
|
||||
:optimizations :none
|
||||
:output-to "resources/public/main.js"
|
||||
:output-dir "resources/public/main.out"
|
||||
:asset-path "/main.out"}
|
|
@ -0,0 +1,2 @@
|
|||
{:open-url "http://localhost:9500"
|
||||
:clean-outputs true}
|
|
@ -0,0 +1,55 @@
|
|||
(defmulti task first)
|
||||
|
||||
(defmethod task :default
|
||||
[[task-name]]
|
||||
(println "Unknown task:" task-name)
|
||||
(System/exit 1))
|
||||
|
||||
(require
|
||||
'[edna.core :as edna]
|
||||
'[music.core :as c]
|
||||
'[cljs.build.api :as api]
|
||||
'[clojure.java.io :as io])
|
||||
|
||||
(defn delete-children-recursively! [f]
|
||||
(when (.isDirectory f)
|
||||
(doseq [f2 (.listFiles f)]
|
||||
(delete-children-recursively! f2)))
|
||||
(when (.exists f) (io/delete-file f)))
|
||||
|
||||
(defmethod task nil
|
||||
[_]
|
||||
(let [out-file "resources/public/main.js"
|
||||
out-dir "resources/public/main.out"]
|
||||
(println "Building main.js")
|
||||
(delete-children-recursively! (io/file out-dir))
|
||||
(api/build "src" {:main 'music.core
|
||||
:optimizations :advanced
|
||||
:output-to out-file
|
||||
:output-dir out-dir
|
||||
:infer-externs true})
|
||||
(delete-children-recursively! (io/file out-dir))
|
||||
(println "Build complete:" out-file)
|
||||
(System/exit 0)))
|
||||
|
||||
(defn export-song-wav [song]
|
||||
(let [wav-name (str song ".wav")
|
||||
build-dir "target"
|
||||
output-file (io/file build-dir wav-name)]
|
||||
(.mkdir (io/file build-dir))
|
||||
(println "Building" wav-name)
|
||||
(edna/export! (c/read-music song) {:type :wav, :out output-file})
|
||||
(println "Build complete:" wav-name)
|
||||
(println "Song saved into:" (.getPath output-file))))
|
||||
|
||||
(defmethod task "wav"
|
||||
[[_ song]]
|
||||
(export-song-wav song)
|
||||
(System/exit 0))
|
||||
|
||||
(defmethod task "soundtrack"
|
||||
[_]
|
||||
(run! #(task ["wav" %]) (c/get-all-songs))
|
||||
(System/exit 0))
|
||||
|
||||
(task *command-line-args*)
|
|
@ -0,0 +1,21 @@
|
|||
(ns music.core
|
||||
(:require [edna.core :as edna]
|
||||
[clojure.java.io :as io]
|
||||
[clojure.string :as string]))
|
||||
|
||||
(def songs-dir "src/music/songs/")
|
||||
|
||||
(defn read-music [song]
|
||||
(load-file (str songs-dir song ".clj")))
|
||||
|
||||
(defn get-all-songs []
|
||||
(map #(string/replace (.getName %) ".clj" "") (.listFiles (io/file songs-dir))))
|
||||
|
||||
(defonce state (atom nil))
|
||||
|
||||
(defn -main [song]
|
||||
(swap! state edna/stop!)
|
||||
(reset! state (edna/play! (read-music song))))
|
||||
|
||||
(defmacro build-for-cljs []
|
||||
(edna/edna->data-uri (read-music "main_theme")))
|
|
@ -0,0 +1,8 @@
|
|||
(ns music.core
|
||||
(:require-macros [music.core :refer [build-for-cljs]]))
|
||||
|
||||
(defonce audio (js/document.createElement "audio"))
|
||||
(set! (.-src audio) (build-for-cljs))
|
||||
(set! (.-controls audio) true)
|
||||
(js/document.body.appendChild audio)
|
||||
(.play audio)
|
|
@ -0,0 +1,16 @@
|
|||
(ns music.songs.main-theme)
|
||||
|
||||
(def tempo 72)
|
||||
|
||||
(defn intro [volume]
|
||||
(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 [70]))
|
|
@ -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:
|
||||
|
|
|
@ -21,6 +21,7 @@ onready var borderless_cb: CheckBox = $MarginContainer/VSplitContainer/CenterCon
|
|||
|
||||
|
||||
func _ready() -> void:
|
||||
auto_clutch_cb.grab_focus()
|
||||
master_slider.value = db2linear(AudioServer.get_bus_volume_db(master_bus))
|
||||
sound_slider.value = db2linear(AudioServer.get_bus_volume_db(sound_bus))
|
||||
music_slider.value = db2linear(AudioServer.get_bus_volume_db(music_bus))
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
extends Node
|
||||
|
||||
export var main_theme: AudioStream
|
||||
|
||||
var current_theme = null
|
||||
|
||||
onready var themes = {"main": main_theme}
|
||||
onready var player: AudioStreamPlayer = $Player
|
||||
|
||||
|
||||
func play_theme(theme: String) -> void:
|
||||
if theme != current_theme:
|
||||
player.stream = themes[theme]
|
||||
player.play()
|
||||
current_theme = theme
|
|
@ -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"
|
|
@ -46,6 +46,7 @@ config/icon="res://icon.png"
|
|||
[autoload]
|
||||
|
||||
GlobalSettings="*res://settings/GlobalSettings.gd"
|
||||
MusicPlayer="*res://music/MusicPlayer.tscn"
|
||||
|
||||
[editor_plugins]
|
||||
|
||||
|
@ -57,6 +58,13 @@ theme/use_hidpi=true
|
|||
|
||||
[input]
|
||||
|
||||
ui_cancel={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777217,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":1,"pressure":0.0,"pressed":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":11,"pressure":0.0,"pressed":false,"script":null)
|
||||
]
|
||||
}
|
||||
throttle={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
OLDWD=$PWD
|
||||
SCRIPTD=$(dirname "$0")
|
||||
ROOTD="$SCRIPTD/.."
|
||||
ASSETS_DIR="$ROOTD/assets"
|
||||
MUSIC_SOURCE_DIR="$ASSETS_DIR/source/music"
|
||||
MUSIC_OUTPUT_DIR="$MUSIC_SOURCE_DIR/target"
|
||||
MUSIC_ASSETS_DIR="$ASSETS_DIR/music"
|
||||
|
||||
echo "Removing all wav files from $MUSIC_OUTPUT_DIR"
|
||||
rm -f "$MUSIC_OUTPUT_DIR/"*.wav
|
||||
cd $MUSIC_SOURCE_DIR
|
||||
|
||||
echo "Building songs"
|
||||
clj -M prod.clj soundtrack
|
||||
|
||||
cd $OLDWD
|
||||
echo "Removing all wav files from $MUSIC_ASSETS_DIR"
|
||||
rm -f "$MUSIC_ASSETS_DIR/"*.wav
|
||||
mv "$MUSIC_OUTPUT_DIR/"*.wav "$MUSIC_ASSETS_DIR/"
|
||||
echo "Moved all songs to $MUSIC_ASSETS_DIR"
|
Loading…
Reference in New Issue