diff --git a/MidiPlayer.Droid/MainActivity.Component.cs b/MidiPlayer.Droid/MainActivity.Component.cs index 08fef30..06e8f0e 100644 --- a/MidiPlayer.Droid/MainActivity.Component.cs +++ b/MidiPlayer.Droid/MainActivity.Component.cs @@ -9,7 +9,7 @@ namespace MidiPlayer.Droid { public partial class MainActivity : AppCompatActivity { /////////////////////////////////////////////////////////////////////////////////////////////// - // private Methods [verb] + // private Methods [verb, verb phrases] /// /// initialize the component. diff --git a/MidiPlayer.Droid/MainActivity.cs b/MidiPlayer.Droid/MainActivity.cs index ecfc158..685954b 100644 --- a/MidiPlayer.Droid/MainActivity.cs +++ b/MidiPlayer.Droid/MainActivity.cs @@ -21,7 +21,7 @@ namespace MidiPlayer.Droid { public partial class MainActivity : AppCompatActivity { /////////////////////////////////////////////////////////////////////////////////////////////// - // Fields + // Fields [nouns, noun phrases] string soundFontPath = "undefined"; @@ -54,22 +54,19 @@ protected override void OnCreate(Bundle savedInstanceState) { initializeComponent(); Conf.Load(); - int _count = 0; - Synth.OnMessage += (IntPtr data, IntPtr evt) => { - //Log.Info($"OnMessage count: {_count}"); - _count++; + Synth.Playbacking += (IntPtr data, IntPtr evt) => { return Synth.HandleEvent(data, evt); }; - Synth.OnStart += () => { - Log.Info("OnStart called."); + Synth.Started += () => { + Log.Info("Started called."); MainThread.BeginInvokeOnMainThread(() => { Title = $"MidiPlayer: {Synth.MidiFilePath.ToFileName()} {Synth.SoundFontPath.ToFileName()}"; }); }; - Synth.OnEnd += () => { - Log.Info("OnEnd called."); + Synth.Ended += () => { + Log.Info("Ended called."); if (!playList.Ready) { Synth.Stop(); Synth.Start(); @@ -436,7 +433,7 @@ void buttonSendSynth_16_Click(object sender, EventArgs e) { } /////////////////////////////////////////////////////////////////////////////////////////////// - // private Methods [verb] + // private Methods [verb, verb phrases] void requestPermissions() { if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.ReadExternalStorage) != (int) Permission.Granted) { diff --git a/MidiPlayer.FluidSynth/Synth.cs b/MidiPlayer.FluidSynth/Synth.cs index 0461dba..de46b37 100644 --- a/MidiPlayer.FluidSynth/Synth.cs +++ b/MidiPlayer.FluidSynth/Synth.cs @@ -20,7 +20,7 @@ namespace MidiPlayer { public class Synth { /////////////////////////////////////////////////////////////////////////////////////////////// - // static Fields + // static Fields [nouns, noun phrases] static fluid_settings_t setting = IntPtr.Zero; @@ -32,13 +32,13 @@ public class Synth { static handle_midi_event_func_t event_callback; - static Func onMessage; + static Func onPlaybacking; - static Action onStart; + static Action onStarted; - static Action onEnd; + static Action onEnded; - static Action onUpdate; + static Action onUpdated; static string soundFontPath; @@ -56,7 +56,7 @@ public class Synth { // static Constructor static Synth() { - onMessage += (void_ptr data, fluid_midi_event_t evt) => { + onPlaybacking += (void_ptr data, fluid_midi_event_t evt) => { Enumerable.Range(0, 16).ToList().ForEach(x => { var _data = EventQueue.Dequeue(x); if (!(_data is null)) { @@ -89,7 +89,7 @@ static Synth() { } /////////////////////////////////////////////////////////////////////////////////////////////// - // static Properties [noun, adjective] + // static Properties [noun, noun phrase, adjective] public static string SoundFontPath { get => soundFontPath; @@ -120,33 +120,33 @@ public static bool Playing { } /////////////////////////////////////////////////////////////////////////////////////////////// - // static Events [adjective] + // static Events [verb, verb phrase] - public static event Func OnMessage { + public static event Func Playbacking { add { - onMessage += value; - event_callback = new handle_midi_event_func_t(onMessage); + onPlaybacking += value; + event_callback = new handle_midi_event_func_t(onPlaybacking); } - remove => onMessage -= value; + remove => onPlaybacking -= value; } - public static event Action OnStart { - add => onStart += value; - remove => onStart -= value; + public static event Action Started { + add => onStarted += value; + remove => onStarted -= value; } - public static event Action OnEnd { - add => onEnd += value; - remove => onEnd -= value; + public static event Action Ended { + add => onEnded += value; + remove => onEnded -= value; } - public static event Action OnUpdate { - add => onUpdate += value; - remove => onUpdate -= value; + public static event Action Updated { + add => onUpdated += value; + remove => onUpdated -= value; } /////////////////////////////////////////////////////////////////////////////////////////////// - // public static Methods [verb] + // public static Methods [verb, verb phrases] public static void Init() { try { @@ -177,7 +177,7 @@ public static void Init() { } Multi.StandardMidiFile = standardMidiFile; Enumerable.Range(0, 16).ToList().ForEach(x => { - Multi.Get(x).PropertyChanged += onUpdateCallBack; + Multi.Get(x).PropertyChanged += onPropertyChanged; }); int _result = fluid_player_add(player, MidiFilePath); if (_result == FLUID_FAILED) { @@ -205,11 +205,11 @@ public static void Start() { adriver = new_fluid_audio_driver(setting, synth); fluid_player_play(player); Log.Info("start :)"); - onStart(); + onStarted(); fluid_player_join(player); Log.Info("end :D"); if (stopping == false) { - onEnd(); + onEnded(); } } catch (Exception ex) { Log.Error(ex.Message); @@ -273,7 +273,7 @@ public static bool IsSounded(int channel) { } /////////////////////////////////////////////////////////////////////////////////////////////// - // private static Methods [verb] + // private static Methods [verb, verb phrases] static void final() { try { @@ -294,8 +294,8 @@ static void final() { } } - static void onUpdateCallBack(object sender, PropertyChangedEventArgs e) { - onUpdate(sender, e); + static void onPropertyChanged(object sender, PropertyChangedEventArgs e) { + onUpdated(sender, e); } /////////////////////////////////////////////////////////////////////////////////////////////// @@ -304,7 +304,7 @@ static void onUpdateCallBack(object sender, PropertyChangedEventArgs e) { static class Multi { /////////////////////////////////////////////////////////////////////////////////////////// - // static Fields + // static Fields [nouns, noun phrases] static Map trackMap; @@ -318,7 +318,7 @@ static Multi() { } /////////////////////////////////////////////////////////////////////////////////////////// - // static Properties [noun, adjective] + // static Properties [noun, noun phrase, adjective] public static List List { get => trackMap.Select(x => x.Value).ToList(); @@ -333,7 +333,7 @@ public static StandardMidiFile StandardMidiFile { } /////////////////////////////////////////////////////////////////////////////////////////// - // public static Methods [verb] + // public static Methods [verb, verb phrases] /// /// NOTE_ON = 144 @@ -394,7 +394,7 @@ public static Track Get(int track) { } /////////////////////////////////////////////////////////////////////////////////////////// - // private static Methods [verb] + // private static Methods [verb, verb phrases] static void init() { trackMap.Clear(); @@ -411,7 +411,7 @@ static void init() { public class Track : INotifyPropertyChanged { /////////////////////////////////////////////////////////////////////////////////////////// - // Fields + // Fields [nouns, noun phrases] int index = -1; @@ -433,7 +433,7 @@ public Track(int index) { } /////////////////////////////////////////////////////////////////////////////////////////// - // Events [adjective] + // Events [verb, verb phrase] /// /// implementation for INotifyPropertyChanged @@ -441,7 +441,7 @@ public Track(int index) { public event PropertyChangedEventHandler PropertyChanged; /////////////////////////////////////////////////////////////////////////////////////////// - // Properties [noun, adjective] + // Properties [noun, noun phrase, adjective] public int Index { get => index; diff --git a/MidiPlayer.Midi/StandardMidiFile.cs b/MidiPlayer.Midi/StandardMidiFile.cs index b29dd0a..cfecce0 100644 --- a/MidiPlayer.Midi/StandardMidiFile.cs +++ b/MidiPlayer.Midi/StandardMidiFile.cs @@ -11,7 +11,7 @@ namespace MidiPlayer.Midi { public class StandardMidiFile { /////////////////////////////////////////////////////////////////////////////////////////////// - // Fields + // Fields [nouns, noun phrases] Sequence sequence; @@ -39,7 +39,7 @@ public StandardMidiFile(string target) { } /////////////////////////////////////////////////////////////////////////////////////////////// - // Properties [noun, adjective] + // Properties [noun, noun phrase, adjective] public int TrackCount { get => sequence.Count - 1; // exclude conductor track; @@ -50,21 +50,21 @@ public List MidiChannelList { } /////////////////////////////////////////////////////////////////////////////////////////////// - // public Methods [verb] + // public Methods [verb, verb phrases] public string GetTrackName(int track) { return nameAndMidiChannelMap[track].name; } /////////////////////////////////////////////////////////////////////////////////////////////// - // private Properties [noun, adjective] + // private Properties [noun, noun phrase, adjective] int trackCountIncludeConductorTrack { get => sequence.Count; } /////////////////////////////////////////////////////////////////////////////////////////////// - // private Methods [verb] + // private Methods [verb, verb phrases] string getTrackName(int track) { var _trackName = "undefined"; diff --git a/MidiPlayer.SoundFont/SoundFont .cs b/MidiPlayer.SoundFont/SoundFont .cs index 6c28d7d..e56383c 100644 --- a/MidiPlayer.SoundFont/SoundFont .cs +++ b/MidiPlayer.SoundFont/SoundFont .cs @@ -10,7 +10,7 @@ namespace MidiPlayer.SoundFont { public class SoundFontInfo { /////////////////////////////////////////////////////////////////////////////////////////////// - // Fields + // Fields [nouns, noun phrases] NAudio.SoundFont.SoundFont soundFont; @@ -42,7 +42,7 @@ public SoundFontInfo(string target) { } /////////////////////////////////////////////////////////////////////////////////////////////// - // public Methods [verb] + // public Methods [verb, verb phrases] public string GetVoice(int bank, int prog) { var _voice = map[bank]; @@ -60,7 +60,7 @@ public string GetVoice(int bank, int prog) { class Voice { /////////////////////////////////////////////////////////////////////////////////////////// - // Properties [noun, adjective] + // Properties [noun, noun phrase, adjective] public int Prog { get; set; diff --git a/MidiPlayer.Win64/BufferedListView.cs b/MidiPlayer.Win64/BufferedListView.cs index 936a9b9..e4ff282 100644 --- a/MidiPlayer.Win64/BufferedListView.cs +++ b/MidiPlayer.Win64/BufferedListView.cs @@ -8,7 +8,7 @@ namespace MidiPlayer.Win64 { public class BufferedListView : ListView { /////////////////////////////////////////////////////////////////////////////////////////////// - // protected Methods [verb] + // protected Methods [verb, verb phrases] protected override bool DoubleBuffered { get { diff --git a/MidiPlayer.Win64/MainForm.cs b/MidiPlayer.Win64/MainForm.cs index f42cc89..f9bc456 100644 --- a/MidiPlayer.Win64/MainForm.cs +++ b/MidiPlayer.Win64/MainForm.cs @@ -13,7 +13,7 @@ namespace MidiPlayer.Win64 { public partial class MainForm : Form { /////////////////////////////////////////////////////////////////////////////////////////////// - // Fields + // Fields [nouns, noun phrases] string soundFontPath = "undefined"; @@ -37,12 +37,12 @@ void MainForm_Load(object sender, EventArgs e) { Conf.Load(); initializeControl(); - Synth.OnMessage += (IntPtr data, IntPtr evt) => { + Synth.Playbacking += (IntPtr data, IntPtr evt) => { return Synth.HandleEvent(data, evt); }; - Synth.OnStart += () => { - Log.Info("OnStart called."); + Synth.Started += () => { + Log.Info("Started called."); Invoke((MethodInvoker) (() => { Text = $"MidiPlayer: {Synth.MidiFilePath.ToFileName()} {Synth.SoundFontPath.ToFileName()}"; listView.Items.Clear(); @@ -52,8 +52,8 @@ void MainForm_Load(object sender, EventArgs e) { })); }; - Synth.OnEnd += () => { - Log.Info("OnEnd called."); + Synth.Ended += () => { + Log.Info("Ended called."); if (!playList.Ready) { Synth.Stop(); Synth.Start(); @@ -64,7 +64,7 @@ void MainForm_Load(object sender, EventArgs e) { } }; - Synth.OnUpdate += (object sender, PropertyChangedEventArgs e) => { + Synth.Updated += (object sender, PropertyChangedEventArgs e) => { var _track = (Synth.Track) sender; Invoke(updateList(_track)); }; @@ -124,7 +124,7 @@ void buttonStop_Click(object sender, EventArgs e) { } /////////////////////////////////////////////////////////////////////////////////////////////// - // private Methods [verb] + // private Methods [verb, verb phrases] async void playSong() { try { diff --git a/MidiPlayer/Conf.cs b/MidiPlayer/Conf.cs index ee475b5..20c135c 100644 --- a/MidiPlayer/Conf.cs +++ b/MidiPlayer/Conf.cs @@ -11,14 +11,14 @@ namespace MidiPlayer { public class Conf { /////////////////////////////////////////////////////////////////////////////////////////////// - // static Fields + // static Fields [nouns, noun phrases] static readonly string APP_CONF_FILE_PATH = "storage/emulated/0/Android/data/com.studio.meowtoon.midiplayer/files/app_conf.json"; static Json json = null; /////////////////////////////////////////////////////////////////////////////////////////////// - // static Properties [noun, adjective] + // static Properties [noun, noun phrase, adjective] public static bool Ready { get => !(json is null); @@ -34,7 +34,7 @@ public static App Value { } /////////////////////////////////////////////////////////////////////////////////////////////// - // public static Methods [verb] + // public static Methods [verb, verb phrases] public static void Load() { if (File.Exists(APP_CONF_FILE_PATH)) { @@ -60,7 +60,7 @@ public static void Save() { } /////////////////////////////////////////////////////////////////////////////////////////////// - // private static Methods [verb] + // private static Methods [verb, verb phrases] static Json loadJson(Stream target) { var _serializer = new DataContractJsonSerializer(typeof(Json)); diff --git a/MidiPlayer/Env.cs b/MidiPlayer/Env.cs index c2e6c6a..2d230d4 100644 --- a/MidiPlayer/Env.cs +++ b/MidiPlayer/Env.cs @@ -6,14 +6,14 @@ namespace MidiPlayer { public class Env { /////////////////////////////////////////////////////////////////////////////////////////////// - // static Fields + // static Fields [nouns, noun phrases] static string soundFontDir = "Music"; static string midiFileDir = "Music"; /////////////////////////////////////////////////////////////////////////////////////////////// - // static Properties [noun, adjective] + // static Properties [noun, noun phrase, adjective] public static string SoundFontDir { get { diff --git a/MidiPlayer/EventQueue.cs b/MidiPlayer/EventQueue.cs index 0087d85..611d830 100644 --- a/MidiPlayer/EventQueue.cs +++ b/MidiPlayer/EventQueue.cs @@ -15,7 +15,7 @@ public class Map : Dictionary { public class EventQueue { /////////////////////////////////////////////////////////////////////////////////////////////// - // static Fields + // static Fields [nouns, noun phrases] static Map> queueMap = new Map>(); @@ -28,7 +28,7 @@ static EventQueue() { } /////////////////////////////////////////////////////////////////////////////////////////////// - // public static Methods [verb] + // public static Methods [verb, verb phrases] public static void Enqueue(int idx, Data value) { queueMap[idx].Enqueue(value); @@ -45,7 +45,7 @@ public static Data Dequeue(int idx) { public class Data { /////////////////////////////////////////////////////////////////////////////////////////////// - // Properties [noun, adjective] + // Properties [noun, noun phrase, adjective] int prog; @@ -54,7 +54,7 @@ public class Data { int vol; /////////////////////////////////////////////////////////////////////////////////////////////// - // Properties [noun, adjective] + // Properties [noun, noun phrase, adjective] public int Prog { get => prog - 1; diff --git a/MidiPlayer/Log.cs b/MidiPlayer/Log.cs index 92b41ad..a87bbae 100644 --- a/MidiPlayer/Log.cs +++ b/MidiPlayer/Log.cs @@ -9,12 +9,12 @@ namespace MidiPlayer { public static class Log { /////////////////////////////////////////////////////////////////////////////////////////////// - // static Fields + // static Fields [nouns, noun phrases] static Logger logger = LogManager.GetCurrentClassLogger(); /////////////////////////////////////////////////////////////////////////////////////////////// - // public static Methods [verb] + // public static Methods [verb, verb phrases] public static void Fatal(string target) { LogEventInfo _event = new LogEventInfo(LogLevel.Fatal, logger.Name, target); diff --git a/MidiPlayer/PlayList.cs b/MidiPlayer/PlayList.cs index 07ee6a9..82c1b09 100644 --- a/MidiPlayer/PlayList.cs +++ b/MidiPlayer/PlayList.cs @@ -8,7 +8,7 @@ namespace MidiPlayer { public class PlayList { /////////////////////////////////////////////////////////////////////////////////////////////// - // Fields + // Fields [nouns, noun phrases] List targetList = new List(); @@ -22,7 +22,7 @@ public PlayList() { } /////////////////////////////////////////////////////////////////////////////////////////////// - // Properties [noun, adjective] + // Properties [noun, noun phrase, adjective] public bool Ready { get => targetList.Count == 0 ? false : true; @@ -46,7 +46,7 @@ public string Next { } /////////////////////////////////////////////////////////////////////////////////////////////// - // public Methods [verb] + // public Methods [verb, verb phrases] public void Add(string target) { targetList.Add(target); diff --git a/MidiPlayerTests/PrivateObject.cs b/MidiPlayerTests/PrivateObject.cs index a197f4d..9106eaf 100644 --- a/MidiPlayerTests/PrivateObject.cs +++ b/MidiPlayerTests/PrivateObject.cs @@ -9,7 +9,7 @@ namespace MidiPlayer { public class PrivateObject { /////////////////////////////////////////////////////////////////////////////////////////////// - // Fields + // Fields [nouns, noun phrases] private readonly object obj; @@ -21,7 +21,7 @@ public PrivateObject(object obj) { } /////////////////////////////////////////////////////////////////////////////////////////////// - // public Methods [verb] + // public Methods [verb, verb phrases] public object Invoke(string methodName, params object[] args) { var _type = obj.GetType(); diff --git a/MidiPlayerTests/SynthTests.cs b/MidiPlayerTests/SynthTests.cs index 6fb4ea8..14b08a1 100644 --- a/MidiPlayerTests/SynthTests.cs +++ b/MidiPlayerTests/SynthTests.cs @@ -73,14 +73,14 @@ public void GetTrackNameTest3() { public void TestInitialize() { Synth.SoundFontPath = "../data/OmegaGMGS2.sf2"; Synth.MidiFilePath = "../data/Cmon_v1.mid"; - Synth.OnMessage += (IntPtr data, IntPtr evt) => { + Synth.Playbacking += (IntPtr data, IntPtr evt) => { return Synth.HandleEvent(data, evt); }; - Synth.OnStart += () => { + Synth.Start += () => { }; - Synth.OnEnd += () => { + Synth.Ended += () => { }; - Synth.OnUpdate += (object sender, PropertyChangedEventArgs e) => { + Synth.Updated += (object sender, PropertyChangedEventArgs e) => { }; playSong(); Sleep(3000); @@ -92,7 +92,7 @@ public void TestCelean() { } /////////////////////////////////////////////////////////////////////////////////////////////// - // private Methods [verb] + // private Methods [verb, verb phrases] async void playSong() { try {