Skip to content

Commit 1c36656

Browse files
authored
Merge pull request #122 from Project-Funk-Engine/BoredDuringBreak
System Overhaul
2 parents 6a25c58 + a7c8c04 commit 1c36656

180 files changed

Lines changed: 2102 additions & 1368 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Audio/midi/Song1.mid

0 Bytes
Binary file not shown.

Audio/midi/Song2.mid

-28 Bytes
Binary file not shown.

Audio/midi/Song3.mid

-2.58 KB
Binary file not shown.

Classes/MidiMaestro/MidiMaestro.cs

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,29 @@
44
using Godot;
55
using Melanchall.DryWetMidi.Core;
66
using Melanchall.DryWetMidi.Interaction;
7-
using Melanchall.DryWetMidi.Multimedia;
87

8+
/**
9+
<summary> MidiMaestro: Manages reading midi file into lane note information.</summary>
10+
11+
*/
912
public partial class MidiMaestro : Resource
1013
{
1114
private MidiFile _midiFile;
1215

13-
public static TempoMap TempoMap;
14-
public static TimeSignature TimeSignature;
16+
public static TempoMap TempoMap { get; private set; }
17+
public static TimeSignature TimeSignature { get; private set; }
1518

1619
//The four note rows that we care about
17-
private midiNoteInfo[] _upNotes;
18-
private midiNoteInfo[] _downNotes;
19-
private midiNoteInfo[] _leftNotes;
20-
private midiNoteInfo[] _rightNotes;
20+
private readonly MidiNoteInfo[] _upNotes;
21+
private readonly MidiNoteInfo[] _downNotes;
22+
private readonly MidiNoteInfo[] _leftNotes;
23+
private readonly MidiNoteInfo[] _rightNotes;
2124

2225
//private MidiFile strippedSong;
23-
24-
//The path relative to the Audio folder. Will change later
26+
/**
27+
* <summary>Constructor loads midi file and populates lane note arrays with midiNoteInfo</summary>
28+
* <param name="filePath">A string file path to a valid midi file</param>
29+
*/
2530
public MidiMaestro(string filePath)
2631
{
2732
if (!OS.HasFeature("editor"))
@@ -42,9 +47,9 @@ public MidiMaestro(string filePath)
4247
foreach (var track in _midiFile.GetTrackChunks())
4348
{
4449
string trackName = track.Events.OfType<SequenceTrackNameEvent>().FirstOrDefault()?.Text;
45-
midiNoteInfo[] noteEvents = track
50+
MidiNoteInfo[] noteEvents = track
4651
.GetNotes()
47-
.Select(note => new midiNoteInfo(note))
52+
.Select(note => new MidiNoteInfo(note))
4853
.ToArray();
4954

5055
switch (trackName)
@@ -65,7 +70,10 @@ public MidiMaestro(string filePath)
6570
}
6671
}
6772

68-
public midiNoteInfo[] GetNotes(ArrowType arrowType)
73+
/**
74+
* <summary>Gets midiNoteInfo by lane. </summary>
75+
*/
76+
public MidiNoteInfo[] GetNotes(ArrowType arrowType)
6977
{
7078
return arrowType switch
7179
{
@@ -79,11 +87,11 @@ public midiNoteInfo[] GetNotes(ArrowType arrowType)
7987
}
8088

8189
//A facade to wrap the midi notes. This is a simple class that wraps a Note object from the DryWetMidi library.
82-
public class midiNoteInfo
90+
public class MidiNoteInfo
8391
{
8492
private readonly Melanchall.DryWetMidi.Interaction.Note _note;
8593

86-
public midiNoteInfo(Melanchall.DryWetMidi.Interaction.Note note)
94+
public MidiNoteInfo(Melanchall.DryWetMidi.Interaction.Note note)
8795
{
8896
_note = note;
8997
}
@@ -100,7 +108,16 @@ public float GetStartTimeSeconds() =>
100108
_note.TimeAs<MetricTimeSpan>(MidiMaestro.TempoMap).Milliseconds / 1000f
101109
+ _note.TimeAs<MetricTimeSpan>(MidiMaestro.TempoMap).Seconds;
102110

103-
public long GetEndTime() => _note.EndTime;
111+
public long GetEndTime() => _note.EndTime; //ticks
112+
113+
public long GetDuration() => _note.Length; //ticks
104114

105-
public long GetDuration() => _note.Length;
115+
public long GetDurationBeats()
116+
{
117+
var beatsBar = TimeConverter.ConvertTo<BarBeatTicksTimeSpan>(
118+
_note.Length,
119+
MidiMaestro.TempoMap
120+
);
121+
return beatsBar.Bars * MidiMaestro.TimeSignature.Numerator + beatsBar.Beats;
122+
}
106123
}

Classes/MidiMaestro/SongTemplate.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
namespace FunkEngine.Classes.MidiMaestro;
22

3-
public partial class SongTemplate
3+
/**
4+
* <summary>SongTemplate: Generic class to represent a rhythm battle.</summary>
5+
*/
6+
public struct SongTemplate
47
{
58
public string Name;
6-
public string AudioLocation;
9+
public readonly string AudioLocation;
710
public string MIDILocation;
8-
public string EnemyScenePath;
11+
public readonly string EnemyScenePath;
912
public SongData SongData;
1013

1114
public SongTemplate(

Classes/Notes/assets/single_note.png.import renamed to Classes/Notes/Assets/Note_PlayerBasic.png.import

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
importer="texture"
44
type="CompressedTexture2D"
55
uid="uid://c3chrsxrulapd"
6-
path="res://.godot/imported/single_note.png-edadc3d6779f4cc26ac823d186717719.ctex"
6+
path="res://.godot/imported/Note_PlayerBasic.png-8e39c4aa6664f4092d3fb2ac9f14cce6.ctex"
77
metadata={
88
"vram_texture": false
99
}
1010

1111
[deps]
1212

13-
source_file="res://Classes/Notes/assets/single_note.png"
14-
dest_files=["res://.godot/imported/single_note.png-edadc3d6779f4cc26ac823d186717719.ctex"]
13+
source_file="res://Classes/Notes/Assets/Note_PlayerBasic.png"
14+
dest_files=["res://.godot/imported/Note_PlayerBasic.png-8e39c4aa6664f4092d3fb2ac9f14cce6.ctex"]
1515

1616
[params]
1717

File renamed without changes.

Classes/Notes/assets/double_note.png.import renamed to Classes/Notes/Assets/Note_PlayerDouble.png.import

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
importer="texture"
44
type="CompressedTexture2D"
55
uid="uid://caw70lr5e1yiq"
6-
path="res://.godot/imported/double_note.png-1b788aee0b7f76d502303d178d821d3b.ctex"
6+
path="res://.godot/imported/Note_PlayerDouble.png-9f112bc39494bd9420dfe4ce034039fa.ctex"
77
metadata={
88
"vram_texture": false
99
}
1010

1111
[deps]
1212

13-
source_file="res://Classes/Notes/assets/double_note.png"
14-
dest_files=["res://.godot/imported/double_note.png-1b788aee0b7f76d502303d178d821d3b.ctex"]
13+
source_file="res://Classes/Notes/Assets/Note_PlayerDouble.png"
14+
dest_files=["res://.godot/imported/Note_PlayerDouble.png-9f112bc39494bd9420dfe4ce034039fa.ctex"]
1515

1616
[params]
1717

0 commit comments

Comments
 (0)