Ejemplo n.º 1
0
        private void MainWindow_Load(object sender, EventArgs e)
        {
            MapReader = new FileMapReader(musicPath.Text + "\\mapping.txt");

            string[] availableSongs = MapReader.GetAvailableSongs();
            songList.Items.AddRange(availableSongs);

            MapReader.Dispose();
        }
Ejemplo n.º 2
0
        public void InitTracks(string songName)
        {
            if (!string.IsNullOrWhiteSpace(SongDirectory))
            {
                MapReader = new FileMapReader(SongDirectory + "\\mapping.txt");

                bool     isMSPInit = false;
                string[] tracks    = MapReader.GetAvailableTracks(songName);

                string musicDirectory = SongDirectory + "\\";

                loopSampleProviders   = new List <LoopSampleProvider>();
                volumeSampleProviders = new Dictionary <string, VolumeSampleProvider>();

                foreach (var track in tracks)
                {
                    string trackFile = MapReader.GetValue(songName, track);
                    int    loopStart = int.Parse(MapReader.GetValue(songName, "loop_start"));
                    int    loopEnd   = int.Parse(MapReader.GetValue(songName, "loop_end"));

                    int.TryParse(MapReader.GetValue(songName, "dly_" + track), out int startSample);

                    var reader = new CustomVorbisWaveReader(musicDirectory + trackFile);
                    loopSampleProviders.Add(new LoopSampleProvider(reader, loopStart, loopEnd, startSample)
                    {
                        Loop = Loop
                    });
                    volumeSampleProviders.Add(track, new VolumeSampleProvider(loopSampleProviders.Last())
                    {
                        Volume = 0.0f
                    });

                    Console.WriteLine($"Added track \"{track}\" for song \"{songName}\".");
                    Console.WriteLine();
                    Console.WriteLine($"Start offset is {startSample}.");
                    Console.WriteLine();

                    if (!isMSPInit)
                    {
                        mixingSampleProvider = new MixingSampleProvider(loopSampleProviders.First().WaveFormat);
                        isMSPInit            = true;
                    }

                    mixingSampleProvider.AddMixerInput(volumeSampleProviders.Last().Value);
                }

                currentSong = songName;

                MapReader.Dispose();
            }
        }
Ejemplo n.º 3
0
        private void SongList_SelectedIndexChanged(object sender, EventArgs e)
        {
            selectedSong = songList.SelectedItem?.ToString();

            if (!string.IsNullOrWhiteSpace(selectedSong))
            {
                MapReader = new FileMapReader(musicPath.Text + "\\mapping.txt");

                bool     offRadioButtonAdded = false;
                string[] trackNames          = MapReader.GetAvailableTracks(selectedSong);

                trackList.Items.Clear();
                mainTracksPanel.Controls.Clear();
                overlayTracksPanel.Controls.Clear();

                foreach (var trackName in trackNames)
                {
                    if (trackName.StartsWith("ins"))
                    {
                        string trackFile = MapReader.GetValue(selectedSong, trackName);

                        trackList.Items.Add(new ListViewItem(new[] { trackName, trackFile }));

                        string friendlyTrackName = "";

                        if (trackName.Contains("qui"))
                        {
                            friendlyTrackName += "Quiet ";
                        }
                        if (trackName.Contains("nml"))
                        {
                            friendlyTrackName += "Normal ";
                        }
                        if (trackName.Contains("med"))
                        {
                            friendlyTrackName += "Medium ";
                        }
                        if (trackName.Contains("8bt"))
                        {
                            friendlyTrackName += "8-bit ";
                        }

                        if (trackName.Contains("voc"))
                        {
                            friendlyTrackName += "Vocals ";
                        }

                        if (int.TryParse(trackName.Split('_').Last(), out int number))
                        {
                            friendlyTrackName += number.ToString();
                        }

                        RadioButton trackRadioButton = new RadioButton()
                        {
                            Text = friendlyTrackName.Trim(),
                            Name = trackName
                        };

                        trackRadioButton.CheckedChanged += TrackRadioButton_CheckedChanged;

                        mainTracksPanel.Controls.Add(trackRadioButton);
                    }
                    else if (trackName.StartsWith("voc"))
                    {
                        if (!offRadioButtonAdded)
                        {
                            RadioButton noneRadioButton = new RadioButton()
                            {
                                Text = "None",
                                Name = "none"
                            };

                            noneRadioButton.CheckedChanged += NoneRadioButton_CheckedChanged;

                            overlayTracksPanel.Controls.Add(noneRadioButton);

                            offRadioButtonAdded = true;
                        }

                        string trackFile = MapReader.GetValue(selectedSong, trackName);

                        trackList.Items.Add(new ListViewItem(new[] { trackName, trackFile }));

                        string numbering = "";

                        if (int.TryParse(trackName.Split('_').Last(), out int number))
                        {
                            numbering = " " + number.ToString();
                        }

                        RadioButton overlayRadioButton = new RadioButton()
                        {
                            Text = "Vocals" + numbering,
                            Name = trackName
                        };

                        overlayRadioButton.CheckedChanged += OverlayRadioButton_CheckedChanged;

                        overlayTracksPanel.Controls.Add(overlayRadioButton);
                    }
                }

                MapReader.Dispose();

                //((RadioButton)mainTracksPanel.Controls[0]).Checked = true;

                //if (overlayTracksPanel.Controls.Count > 0)
                //    ((RadioButton)overlayTracksPanel.Controls[0]).Checked = true;

                trackList.Sorting = SortOrder.Ascending;
                trackList.Sort();
            }
        }