Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Audio/midi/Song1.mid
Binary file not shown.
Binary file modified Audio/midi/Song2.mid
Binary file not shown.
Binary file modified Audio/midi/Song3.mid
Binary file not shown.
49 changes: 33 additions & 16 deletions Classes/MidiMaestro/MidiMaestro.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,29 @@
using Godot;
using Melanchall.DryWetMidi.Core;
using Melanchall.DryWetMidi.Interaction;
using Melanchall.DryWetMidi.Multimedia;

/**
<summary> MidiMaestro: Manages reading midi file into lane note information.</summary>

*/
public partial class MidiMaestro : Resource
{
private MidiFile _midiFile;

public static TempoMap TempoMap;
public static TimeSignature TimeSignature;
public static TempoMap TempoMap { get; private set; }
public static TimeSignature TimeSignature { get; private set; }

//The four note rows that we care about
private midiNoteInfo[] _upNotes;
private midiNoteInfo[] _downNotes;
private midiNoteInfo[] _leftNotes;
private midiNoteInfo[] _rightNotes;
private readonly MidiNoteInfo[] _upNotes;
private readonly MidiNoteInfo[] _downNotes;
private readonly MidiNoteInfo[] _leftNotes;
private readonly MidiNoteInfo[] _rightNotes;

//private MidiFile strippedSong;

//The path relative to the Audio folder. Will change later
/**
* <summary>Constructor loads midi file and populates lane note arrays with midiNoteInfo</summary>
* <param name="filePath">A string file path to a valid midi file</param>
*/
public MidiMaestro(string filePath)
{
if (!OS.HasFeature("editor"))
Expand All @@ -42,9 +47,9 @@ public MidiMaestro(string filePath)
foreach (var track in _midiFile.GetTrackChunks())
{
string trackName = track.Events.OfType<SequenceTrackNameEvent>().FirstOrDefault()?.Text;
midiNoteInfo[] noteEvents = track
MidiNoteInfo[] noteEvents = track
.GetNotes()
.Select(note => new midiNoteInfo(note))
.Select(note => new MidiNoteInfo(note))
.ToArray();

switch (trackName)
Expand All @@ -65,7 +70,10 @@ public MidiMaestro(string filePath)
}
}

public midiNoteInfo[] GetNotes(ArrowType arrowType)
/**
* <summary>Gets midiNoteInfo by lane. </summary>
*/
public MidiNoteInfo[] GetNotes(ArrowType arrowType)
{
return arrowType switch
{
Expand All @@ -79,11 +87,11 @@ public midiNoteInfo[] GetNotes(ArrowType arrowType)
}

//A facade to wrap the midi notes. This is a simple class that wraps a Note object from the DryWetMidi library.
public class midiNoteInfo
public class MidiNoteInfo
{
private readonly Melanchall.DryWetMidi.Interaction.Note _note;

public midiNoteInfo(Melanchall.DryWetMidi.Interaction.Note note)
public MidiNoteInfo(Melanchall.DryWetMidi.Interaction.Note note)
{
_note = note;
}
Expand All @@ -100,7 +108,16 @@ public float GetStartTimeSeconds() =>
_note.TimeAs<MetricTimeSpan>(MidiMaestro.TempoMap).Milliseconds / 1000f
+ _note.TimeAs<MetricTimeSpan>(MidiMaestro.TempoMap).Seconds;

public long GetEndTime() => _note.EndTime;
public long GetEndTime() => _note.EndTime; //ticks

public long GetDuration() => _note.Length; //ticks

public long GetDuration() => _note.Length;
public long GetDurationBeats()
{
var beatsBar = TimeConverter.ConvertTo<BarBeatTicksTimeSpan>(
_note.Length,
MidiMaestro.TempoMap
);
return beatsBar.Bars * MidiMaestro.TimeSignature.Numerator + beatsBar.Beats;
}
}
9 changes: 6 additions & 3 deletions Classes/MidiMaestro/SongTemplate.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
namespace FunkEngine.Classes.MidiMaestro;

public partial class SongTemplate
/**
* <summary>SongTemplate: Generic class to represent a rhythm battle.</summary>
*/
public struct SongTemplate
{
public string Name;
public string AudioLocation;
public readonly string AudioLocation;
public string MIDILocation;
public string EnemyScenePath;
public readonly string EnemyScenePath;
public SongData SongData;

public SongTemplate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://c3chrsxrulapd"
path="res://.godot/imported/single_note.png-edadc3d6779f4cc26ac823d186717719.ctex"
path="res://.godot/imported/Note_PlayerBasic.png-8e39c4aa6664f4092d3fb2ac9f14cce6.ctex"
metadata={
"vram_texture": false
}

[deps]

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

[params]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://caw70lr5e1yiq"
path="res://.godot/imported/double_note.png-1b788aee0b7f76d502303d178d821d3b.ctex"
path="res://.godot/imported/Note_PlayerDouble.png-9f112bc39494bd9420dfe4ce034039fa.ctex"
metadata={
"vram_texture": false
}

[deps]

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

[params]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://cdf3g3174du4r"
path="res://.godot/imported/heal_note.png-09ca289a296eee82d33c64101a4e593a.ctex"
path="res://.godot/imported/Note_PlayerHeal.png-5679ecbd30dd234cfea43cc6fb83ee76.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Classes/Notes/assets/heal_note.png"
dest_files=["res://.godot/imported/heal_note.png-09ca289a296eee82d33c64101a4e593a.ctex"]
source_file="res://Classes/Notes/Assets/Note_PlayerHeal.png"
dest_files=["res://.godot/imported/Note_PlayerHeal.png-5679ecbd30dd234cfea43cc6fb83ee76.ctex"]

[params]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://uksjoqp7p0gq"
path="res://.godot/imported/quarter_note.png-2b4c9985d99038807abfd63e553c2d6a.ctex"
path="res://.godot/imported/Note_PlayerQuarter.png-b678f5b1b075ececef380edabf9dfb63.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Classes/Notes/assets/quarter_note.png"
dest_files=["res://.godot/imported/quarter_note.png-2b4c9985d99038807abfd63e553c2d6a.ctex"]
source_file="res://Classes/Notes/Assets/Note_PlayerQuarter.png"
dest_files=["res://.godot/imported/Note_PlayerQuarter.png-b678f5b1b075ececef380edabf9dfb63.ctex"]

[params]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://dg0lmu0pip4lr"
path="res://.godot/imported/vampire_note.png-4331f817a6feee1f1066a9e9f95934c8.ctex"
path="res://.godot/imported/Note_PlayerVampire.png-038429e14b819cbb968ff50682ccabc6.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Classes/Notes/assets/vampire_note.png"
dest_files=["res://.godot/imported/vampire_note.png-4331f817a6feee1f1066a9e9f95934c8.ctex"]
source_file="res://Classes/Notes/Assets/Note_PlayerVampire.png"
dest_files=["res://.godot/imported/Note_PlayerVampire.png-038429e14b819cbb968ff50682ccabc6.ctex"]

[params]

Expand Down
14 changes: 10 additions & 4 deletions Classes/Notes/Note.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
using Godot;

/**
* @class Note
* @brief Data structure class for holding data and methods for a battle time note. WIP
* <summary>Note: Data structure class for holding data and methods for a battle time note.</summary>
*/
public partial class Note : Resource, IDisplayable
{
Expand All @@ -15,6 +14,8 @@ public partial class Note : Resource, IDisplayable
public float CostModifier { get; private set; }
private Action<BattleDirector, Note, Timing> NoteEffect;

public const double TimingMax = 0.5d; //The max range for a note to be timed is its beat +/- this const

public string Tooltip { get; set; }
public Texture2D Texture { get; set; }

Expand All @@ -35,9 +36,9 @@ public Note(
NoteEffect =
noteEffect
?? (
(BD, source, Timing) =>
(BD, source, timing) =>
{
BD.GetTarget(this).TakeDamage((int)Timing * source._baseVal);
BD.GetTarget(this).TakeDamage((int)timing * source._baseVal);
}
);
_baseVal = baseVal;
Expand Down Expand Up @@ -68,6 +69,11 @@ public Note Clone()
return newNote;
}

public bool IsPlayerNote()
{
return Name.Contains("Player");
}

public int GetBaseVal()
{
return _baseVal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://cqlrv1vra4mbn"
path="res://.godot/imported/Auroboros.png-27bfe2114f3955a0f6ef5ceb4e65adbf.ctex"
path="res://.godot/imported/Relic_Auroboros.png-c5b164882e0cc6b4eae662aec80abbce.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Classes/Relics/assets/Auroboros.png"
dest_files=["res://.godot/imported/Auroboros.png-27bfe2114f3955a0f6ef5ceb4e65adbf.ctex"]
source_file="res://Classes/Relics/Assets/Relic_Auroboros.png"
dest_files=["res://.godot/imported/Relic_Auroboros.png-c5b164882e0cc6b4eae662aec80abbce.ctex"]

[params]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://ccd6pskxcwpxg"
path="res://.godot/imported/Colorboros.png-56197d792c620150c773fb4ecce6289c.ctex"
path="res://.godot/imported/Relic_Colorboros.png-406af684be0b51f2232e99d2ace4dff9.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Classes/Relics/assets/Colorboros.png"
dest_files=["res://.godot/imported/Colorboros.png-56197d792c620150c773fb4ecce6289c.ctex"]
source_file="res://Classes/Relics/Assets/Relic_Colorboros.png"
dest_files=["res://.godot/imported/Relic_Colorboros.png-406af684be0b51f2232e99d2ace4dff9.ctex"]

[params]

Expand Down
3 changes: 3 additions & 0 deletions Classes/Relics/RelicEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
using FunkEngine;
using Godot;

/**
* <summary>RelicEffect: BattleDirector effect as handled by a player passive relic.</summary>
*/
public partial class RelicEffect : IBattleEvent
{
private BattleEffectTrigger Trigger { get; set; }
Expand Down
6 changes: 4 additions & 2 deletions Classes/Relics/RelicTemplate.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System;
using FunkEngine;
using Godot;

/**
* <summary>RelicTemplate: Generic class representing a player passive relic.</summary>
*/
public partial class RelicTemplate : Resource, IDisplayable
{
public RelicEffect[] Effects;
public readonly RelicEffect[] Effects;
public int Id;
public string Name { get; set; }

Expand Down
6 changes: 3 additions & 3 deletions Classes/Relics/assets/relic_Breakfast.png.import
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://csjx2hb4tdlw8"
path="res://.godot/imported/relic_Breakfast.png-c1b968058adbb855fcf957a2aec74dc2.ctex"
path="res://.godot/imported/Relic_Breakfast.png-71ab89b12909df408626427d83246628.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Classes/Relics/assets/relic_Breakfast.png"
dest_files=["res://.godot/imported/relic_Breakfast.png-c1b968058adbb855fcf957a2aec74dc2.ctex"]
source_file="res://Classes/Relics/Assets/Relic_Breakfast.png"
dest_files=["res://.godot/imported/Relic_Breakfast.png-71ab89b12909df408626427d83246628.ctex"]

[params]

Expand Down
6 changes: 3 additions & 3 deletions Classes/Relics/assets/relic_GoodVibes.png.import
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://dg4tnp7plxmp7"
path="res://.godot/imported/relic_GoodVibes.png-cd102b29bb163411bb7ce8cf724ef0c0.ctex"
path="res://.godot/imported/Relic_GoodVibes.png-01d38d3d6a79fe959565a2bfe43c64ca.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Classes/Relics/assets/relic_GoodVibes.png"
dest_files=["res://.godot/imported/relic_GoodVibes.png-cd102b29bb163411bb7ce8cf724ef0c0.ctex"]
source_file="res://Classes/Relics/Assets/Relic_GoodVibes.png"
dest_files=["res://.godot/imported/Relic_GoodVibes.png-01d38d3d6a79fe959565a2bfe43c64ca.ctex"]

[params]

Expand Down
4 changes: 3 additions & 1 deletion Funk Engine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
<RootNamespace>FunkEngine</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Content Include="Globals\translations.csv" />
<PackageReference Include="Melanchall.DryWetMidi" Version="7.2.0" />
</ItemGroup>
<ItemGroup>
<Content Include="Globals\Translations\translations.csv" />
</ItemGroup>
<Target Name="Husky" BeforeTargets="Restore;CollectPackageReferences" Condition="'$(HUSKY)' != 0">
<Exec Command="dotnet tool restore" StandardOutputImportance="Low" StandardErrorImportance="High" />
<Exec Command="dotnet husky install" StandardOutputImportance="Low" StandardErrorImportance="High" WorkingDirectory="." />
Expand Down
15 changes: 13 additions & 2 deletions Globals/BgAudioPlayer/BgAudioPlayer.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
using Godot;

/**
* <summary>BgAudioPlayer: Autoload to play scene persistant music.</summary>
*/
public partial class BgAudioPlayer : AudioStreamPlayer
{
private readonly AudioStream _levelMusic = (AudioStream)
ResourceLoader.Load("res://scenes/SceneTransitions/assets/titleSong.ogg");
private readonly AudioStream _levelMusic = ResourceLoader.Load<AudioStream>(
"res://Scenes/UI/TitleScreen/Assets/TitleSong.ogg"
);

public static BgAudioPlayer LiveInstance { get; private set; }

public override void _EnterTree()
{
LiveInstance = this;
}

private void PlayMusic(AudioStream music, float volume)
{
Expand Down
Loading