-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainModule.cs
161 lines (154 loc) · 4.45 KB
/
MainModule.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
using Common;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GoldMidiPlayer
{
#region STATES
[Flags]
public enum States {
Idle = 0b_0000_0000,
Midi_loaded = 0b_0000_0001,
Sound_font_loaded = 0b_0000_0010,
All_loaded = 0b_0000_0011
}
#endregion
public class MainModule : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
#region MAIN VIEW VALUES
private States _state;
public States state
{
get { return _state; }
set
{
_state = value;
}
}
private int _globalVolume;
public int GlobalVolume
{
get { return _globalVolume; }
set
{
_globalVolume = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("GlobalVolume"));
}
}
private int _globalPitch;
public int GlobalPitch
{
get { return _globalPitch; }
set
{
_globalPitch = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("GlobalPitch"));
}
}
private int _globalTempo;
public int GlobalTempo
{
get { return _globalTempo; }
set
{
_globalTempo = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("GlobalTempo"));
}
}
private string _displayName;
public string DisplayName
{
get { return _displayName; }
set
{
_displayName = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("DisplayName"));
}
}
private string _displayKey;
public string DisplayKey
{
get
{
if (_displayKey != null)
return Utility.ExtractKey(_displayKey);
return "N/A";
}
set
{
_displayKey = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("DisplayKey"));
}
}
private double _positionInTime;
public double PositionInTime
{
get { return _positionInTime; }
set
{
_positionInTime = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("PositionInTime"));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("PositionInTimeToString"));
}
}
public string PositionInTimeToString
{
get
{
return Utility.SecondsToTime(_positionInTime);
}
}
private double _midiLenght;
public double MidiLenght
{
get { return _midiLenght; }
set
{
_midiLenght = value;
Debug.WriteLine("Setting value in MidiLenght: {0}", value);
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("MidiLenght"));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("MidiLenghtToString"));
}
}
public string MidiLenghtToString
{
get
{
return Utility.SecondsToTime(_midiLenght);
}
}
private PlaylistModel _activePlaylist;
public PlaylistModel ActivePlaylist
{
get { return _activePlaylist; }
set
{
_activePlaylist = value;
}
}
#endregion
#region METHODS
internal void InitPlaylist()
{
List<MidiFile> songs = new List<MidiFile>();
ActivePlaylist = new PlaylistModel("Default", songs);
}
internal void AddMidiFile(MidiFile midiFile)
{
ActivePlaylist.AddSong(midiFile);
DisplayName = midiFile.Name;
DisplayKey = midiFile.TimeSignatureAsString;
MidiLenght = midiFile.Lenght;
}
public MidiFile GetMidiFile()
{
return ActivePlaylist.GetCurrentSong();
}
#endregion
}
}