Skip to content

Commit 9ac9c42

Browse files
authored
Merge pull request #104 from Project-Funk-Engine/cleanup
Cleanup code and last features
2 parents 1d75814 + 29d91a1 commit 9ac9c42

23 files changed

Lines changed: 219 additions & 132 deletions

Audio/midi/Song2.mid

-1.68 KB
Binary file not shown.

Classes/MidiMaestro/MidiMaestro.cs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ public partial class MidiMaestro : Resource
1010
{
1111
private MidiFile _midiFile;
1212

13+
public static TempoMap TempoMap;
14+
public static TimeSignature TimeSignature;
15+
1316
//The four note rows that we care about
1417
private midiNoteInfo[] _upNotes;
1518
private midiNoteInfo[] _downNotes;
@@ -28,18 +31,20 @@ public MidiMaestro(string filePath)
2831

2932
if (!FileAccess.FileExists(filePath))
3033
{
31-
GD.PrintErr("ERROR: Unable to load level Midi file: " + filePath);
34+
GD.PushError("ERROR: Unable to load level Midi file: " + filePath);
3235
}
3336

3437
_midiFile = MidiFile.Read(filePath);
38+
TempoMap = _midiFile.GetTempoMap();
39+
TimeSignature = TempoMap.GetTimeSignatureAtTime(new MidiTimeSpan());
3540

3641
//Strip out the notes from the midi file
3742
foreach (var track in _midiFile.GetTrackChunks())
3843
{
3944
string trackName = track.Events.OfType<SequenceTrackNameEvent>().FirstOrDefault()?.Text;
4045
midiNoteInfo[] noteEvents = track
4146
.GetNotes()
42-
.Select(note => new midiNoteInfo(note, _midiFile.GetTempoMap()))
47+
.Select(note => new midiNoteInfo(note))
4348
.ToArray();
4449

4550
switch (trackName)
@@ -77,19 +82,23 @@ public midiNoteInfo[] GetNotes(ArrowType arrowType)
7782
public class midiNoteInfo
7883
{
7984
private readonly Melanchall.DryWetMidi.Interaction.Note _note;
80-
private readonly TempoMap _tempoMap;
8185

82-
public midiNoteInfo(Melanchall.DryWetMidi.Interaction.Note note, TempoMap tempoMap)
86+
public midiNoteInfo(Melanchall.DryWetMidi.Interaction.Note note)
8387
{
8488
_note = note;
85-
_tempoMap = tempoMap;
89+
}
90+
91+
public long GetStartTimeBeat()
92+
{
93+
var beatsBar = _note.TimeAs<BarBeatTicksTimeSpan>(MidiMaestro.TempoMap);
94+
return beatsBar.Bars * MidiMaestro.TimeSignature.Numerator + beatsBar.Beats;
8695
}
8796

8897
public long GetStartTimeTicks() => _note.Time;
8998

9099
public float GetStartTimeSeconds() =>
91-
_note.TimeAs<MetricTimeSpan>(_tempoMap).Milliseconds / 1000f
92-
+ _note.TimeAs<MetricTimeSpan>(_tempoMap).Seconds;
100+
_note.TimeAs<MetricTimeSpan>(MidiMaestro.TempoMap).Milliseconds / 1000f
101+
+ _note.TimeAs<MetricTimeSpan>(MidiMaestro.TempoMap).Seconds;
93102

94103
public long GetEndTime() => _note.EndTime;
95104

Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[gd_scene load_steps=2 format=3 uid="uid://csx04jwaoo20u"]
22

3-
[ext_resource type="Script" path="res://Globals/BgAudioPlayer.cs" id="1_w7def"]
3+
[ext_resource type="Script" path="res://Globals/BgAudioPlayer/BgAudioPlayer.cs" id="1_w7def"]
44

55
[node name="BgAudioPlayer" type="AudioStreamPlayer"]
66
script = ExtResource("1_w7def")
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[remap]
2+
3+
importer="csv_translation"
4+
type="Translation"
5+
uid="uid://drjnsd6mqpxqh"
6+
7+
[deps]
8+
9+
files=["res://Globals/Translations/translations.en.translation", "res://Globals/Translations/translations.cn.translation"]
10+
11+
source_file="res://Globals/Translations/translations.csv"
12+
dest_files=["res://Globals/Translations/translations.en.translation", "res://Globals/Translations/translations.cn.translation"]
13+
14+
[params]
15+
16+
compress=true
17+
delimiter=0

Globals/translations.csv.import

Lines changed: 0 additions & 17 deletions
This file was deleted.

project.godot

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ buses/default_bus_layout=""
2424
StageProducer="*res://Globals/StageProducer.cs"
2525
TimeKeeper="*res://Globals/TimeKeeper.cs"
2626
Scribe="*res://Globals/Scribe.cs"
27-
BgAudioPlayer="*res://Globals/BGAudioPlayer.tscn"
27+
BgAudioPlayer="*res://Globals/BgAudioPlayer/BGAudioPlayer.tscn"
2828

2929
[display]
3030

3131
window/size/viewport_width=640
3232
window/size/viewport_height=360
33-
window/stretch/mode="viewport"
33+
window/stretch/mode="canvas_items"
3434
window/stretch/scale_mode="integer"
3535

3636
[dotnet]
@@ -191,7 +191,7 @@ QWERT_arrowRight={
191191

192192
[internationalization]
193193

194-
locale/translations=PackedStringArray("res://Globals/translations.cn.translation", "res://Globals/translations.en.translation")
194+
locale/translations=PackedStringArray("res://Globals/Translations/translations.cn.translation", "res://Globals/Translations/translations.en.translation")
195195

196196
[rendering]
197197

scenes/BattleDirector/NotePlacementBar.tscn

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ script = ExtResource("1_456es")
6060
notePlacementBar = NodePath("ProgressBar")
6161
currentComboMultText = NodePath("TextEdit")
6262
_particles = NodePath("ProgressBar/Rock")
63-
_currentNote = NodePath("NoteQueueSprite/NextNote")
64-
_nextNote = NodePath("NoteQueueSprite/CurrentNote")
63+
_currentNote = NodePath("NoteQueueSprite/CurrentNote")
64+
_nextNote = NodePath("NoteQueueSprite/NextNote")
6565
fullBarParticles = NodePath("ProgressBar/CPUParticles2D")
6666

6767
[node name="ProgressBar" type="TextureProgressBar" parent="."]
19.5 KB
Loading

0 commit comments

Comments
 (0)