Skip to content

Commit

Permalink
refactor: #13 keeping codes clean.
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroxpepe committed Mar 18, 2022
1 parent f4c29ce commit c2f9bfb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion MidiPlayer.Droid/MainActivity.EventCallback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void buttonSendSynth_Click(object sender, EventArgs e) {
Volume = fader.Volume,
Mute = !fader.Sounds
};
EventQueue.Enqueue(fader.Channel, data); // FIXME: Channel to track.
EventQueue.Enqueue(fader.Index, data);
} catch (Exception ex) {
Log.Error(ex.Message);
}
Expand Down
6 changes: 6 additions & 0 deletions MidiPlayer.Droid/MainActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ void requestPermissions() {
}
}

/// <summary>
/// call Intent.
/// </summary>
void callIntent(string targetDir, int requestCode) {
var intent = new Intent(Intent.ActionOpenDocument);
var uri = Android.Net.Uri.Parse($"content://com.android.externalstorage.documents/document/primary%3A{targetDir}");
Expand All @@ -306,6 +309,9 @@ void callIntent(string targetDir, int requestCode) {
StartActivityForResult(intent, requestCode);
}

/// <summary>
/// get an actual path.
/// </summary>
static string getActualPathBy(Intent data) {
var uri = data.Data;
string docId = DocumentsContract.GetDocumentId(uri);
Expand Down
10 changes: 5 additions & 5 deletions MidiPlayer.FluidSynth/Synth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,15 @@ static Synth() {
Enumerable.Range(MIDI_TRACK_BASE, MIDI_TRACK_COUNT).ToList().ForEach(trackIdx => {
var eventData = EventQueue.Dequeue(trackIdx);
if (eventData is not null) {
fluid_synth_program_change(_synth, trackIdx, eventData.Program);
fluid_synth_cc(_synth, trackIdx, (int) ControlChange.Pan, eventData.Pan);
fluid_synth_program_change(_synth, eventData.Channel, eventData.Program);
fluid_synth_cc(_synth, eventData.Channel, (int) ControlChange.Pan, eventData.Pan);
if (eventData.Mute) {
fluid_synth_cc(_synth, trackIdx, (int) ControlChange.Volume, MUTE_VOLUME);
fluid_synth_cc(_synth, eventData.Channel, (int) ControlChange.Volume, MUTE_VOLUME);
} else {
fluid_synth_cc(_synth, trackIdx, (int) ControlChange.Volume, eventData.Volume);
fluid_synth_cc(_synth, eventData.Channel, (int) ControlChange.Volume, eventData.Volume);
}
Task.Run(() => {
Multi.ApplyProgramChange(trackIdx, eventData.Program);
Multi.ApplyProgramChange(eventData.Channel, eventData.Program);
});
}
});
Expand Down

0 comments on commit c2f9bfb

Please sign in to comment.