Exemplo n.º 1
0
        void LoadSong(object sender, EventArgs e)
        {
            APlaylist    mainPlaylist = ROM.Instance.Game.Playlists[0];
            List <ASong> songs        = mainPlaylist.Songs.ToList();
            ASong        song         = songs.SingleOrDefault(s => s.Index == songNumerical.Value);

            if (song != null)
            {
                Text = "GBA Music Studio - " + song.Name;
                songsComboBox.SelectedIndex = songs.IndexOf(song) + 1; // + 1 for the Playlist index
            }
            else
            {
                Text = "GBA Music Studio";
                songsComboBox.SelectedIndex = 0;
            }
            bool playing = SongPlayer.Instance.State == PlayerState.Playing; // Play new song if one is already playing
            bool paused  = SongPlayer.Instance.State == PlayerState.Paused;

            Stop(null, null);
            try
            {
                // Pause which stops the thread inside from processing during loading, which would increase the stream latency
                if (!paused)
                {
                    SongPlayer.Instance.Pause();
                }
                var loadedSong = ROM.Instance.SongTables[(int)tableNumerical.Value][(int)songNumerical.Value];
                SongPlayer.Instance.SetSong(loadedSong);
                // Then "un pause" it, setting it to the stopped state
                if (!paused)
                {
                    SongPlayer.Instance.Stop();
                }
                UpdateTrackInfo(playing);
                MIDIKeyboard.Instance.Start();
            }
            catch (Exception ex)
            {
                FlexibleMessageBox.Show(ex.Message, "Error Loading Song " + songNumerical.Value);
                return;
            }
        }
Exemplo n.º 2
0
        void ExportMIDI(object sender, EventArgs e)
        {
            var d = new SaveFileDialog {
                Title = "Esporta File MIDI", Filter = "File MIDI|*.mid"
            };

            if (d.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            try
            {
                SongPlayer.Instance.Song.SaveAsMIDI(d.FileName);
                FlexibleMessageBox.Show($"Canzone salvata in {d.FileName}.", Text);
            }
            catch (Exception ex)
            {
                FlexibleMessageBox.Show(ex.Message, "Errore Nell'Esportazione Della Canzone");
            }
        }
Exemplo n.º 3
0
        void ExportSF2(object sender, EventArgs e)
        {
            var d = new SaveFileDialog {
                Title = "Esporta File SF2", Filter = "File SF2|*.sf2"
            };

            if (d.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            try
            {
                VoiceTableSaver.Save(d.FileName);
                FlexibleMessageBox.Show($"Voicetable salvata in {d.FileName}.", Text);
            }
            catch (Exception ex)
            {
                FlexibleMessageBox.Show(ex.Message, "Errore Nell'Esportazione Del File SF2");
            }
        }
Exemplo n.º 4
0
        void ExportMIDI(object sender, EventArgs e)
        {
            var d = new SaveFileDialog {
                Title = "Export MIDI File", Filter = "MIDI file|*.mid"
            };

            if (d.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            try
            {
                SongPlayer.Instance.Song.SaveAsMIDI(d.FileName);
                FlexibleMessageBox.Show($"Song saved to {d.FileName}.", Text);
            }
            catch (Exception ex)
            {
                FlexibleMessageBox.Show(ex.Message, "Error Exporting Song");
            }
        }
Exemplo n.º 5
0
        void ExportSF2(object sender, EventArgs e)
        {
            var d = new SaveFileDialog {
                Title = "Export SF2 File", Filter = "SF2 file|*.sf2"
            };

            if (d.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            try
            {
                VoiceTableSaver.Save(d.FileName);
                FlexibleMessageBox.Show($"Voice table saved to {d.FileName}.", Text);
            }
            catch (Exception ex)
            {
                FlexibleMessageBox.Show(ex.Message, "Error Exporting SF2 File");
            }
        }
Exemplo n.º 6
0
        void OpenMIDI(object sender, EventArgs e)
        {
            var d = new OpenFileDialog {
                Title = "Open MIDI", Filter = "MIDI files|*.mid"
            };

            if (d.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            try
            {
                midiFileName = d.FileName;
                var process = new Process
                {
                    StartInfo = new ProcessStartInfo
                    {
                        FileName  = "mid2agb.exe",
                        Arguments = string.Format("\"{0}\" \"{1}\"", d.FileName, "temp.s")
                    }
                };
                process.Start();
                process.WaitForExit();
                assembler = new Assembler("temp.s", ROM.Pak, new Dictionary <string, int> {
                    { "voicegroup000", (int)(ROM.Pak + offsetValueBox.Value) }
                });
                File.Delete("temp.s");
                sizeLabel.Text        = $"Size in bytes: {assembler.BinaryLength}";
                previewButton.Enabled = true;
            }
            catch
            {
                FlexibleMessageBox.Show("There was an error converting the MIDI file.", "Error Converting MIDI", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 7
0
        void OpenROM(object sender, EventArgs e)
        {
            var d = new OpenFileDialog {
                Title = "Open GBA ROM", Filter = "GBA files|*.gba"
            };

            if (d.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            Stop(null, null);

            try
            {
                new ROM(d.FileName);
                UpdateMenuInfo();
                LoadSong(null, null);
            }
            catch (Exception ex)
            {
                FlexibleMessageBox.Show(ex.Message, "Error Loading ROM");
            }
        }