private void cmdSave_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                NoteFileLoader.SaveNotes(sfd.FileName, this.currentSong.Frequencies);
            }
        }
        private void cmdLoadFrequencies_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Multiselect = false;
            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                currentSong.Frequencies = NoteFileLoader.LoadNotes(ofd.FileName);
                rbCustom.Checked        = true;
            }
        }
Esempio n. 3
0
        private void initializeSong()
        {
            this.CurrentSong       = new Song(Song.DEFAULT_CHANNELS_COUNT);
            this.currentSong.Name  = WYZTracker.Properties.Resources.NewSong;
            this.currentSong.Tempo = 4;
            this.currentPattern    = this.currentSong.Patterns[0];
            this.currentSong.PlayOrder.Add(0);
            this.currentSong.Frequencies = NoteFileLoader.LoadDefaultNotes();

            this.CurrentInstrument = this.currentSong.Instruments[0];
            this.CurrentEffect     = null;
        }
Esempio n. 4
0
        public static Song LoadSong(Stream stream)
        {
            Song result = null;

            using (Stream objFileStream = SongManager.GetStream(stream))
            {
                XmlSerializer formatter = new XmlSerializer(typeof(Song));
                result = (Song)formatter.Deserialize(objFileStream);
            }

            // Fix para cargar instrumentos de archivos antiguos y que el tema no se
            // fastidie.
            foreach (Instrument instrument in result.Instruments)
            {
                if (instrument.Volumes != null && instrument.PitchModifiers == null)
                {
                    instrument.SetVolumeLength(instrument.Volumes.Length);
                }
            }
            foreach (Effect effect in result.Effects)
            {
                if (effect.Volumes != null && effect.EnvTypes == null)
                {
                    effect.SetEffectLength(effect.Volumes.Length);
                }
            }

            if (result.Frequencies == null || result.Frequencies.Length == 0)
            {
                result.Frequencies = NoteFileLoader.LoadDefaultNotes();
            }

            if (result.ChipFrequency == 0)
            {
                result.ChipFrequency = (int)LibAYEmu.ChipSpeedsByMachine.MSX;
            }

            if (!result.DefaultCpcFreqs && !result.DefaultMsxFreqs && !result.CustomFreqs && !result.ParameterizedFreqs)
            {
                result.DefaultMsxFreqs = true;
                result.ParameterValue  = result.ChipFrequency;
            }

            return(result);
        }
Esempio n. 5
0
        private void initializeSong()
        {
            this.CurrentSong       = new Song(Song.DEFAULT_CHANNELS_COUNT);
            this.currentSong.Name  = WYZTracker.Properties.Resources.NewSong;
            this.currentSong.Tempo = 4;
            this.currentPattern    = this.currentSong.Patterns[0];
            this.currentSong.PlayOrder.Add(0);
            this.currentSong.Frequencies = NoteFileLoader.LoadDefaultNotes();

            this.CurrentInstrument = this.currentSong.Instruments[0];
            this.CurrentEffect     = null;

            if (ApplicationState.Instance.CommandList != null)
            {
                ApplicationState.Instance.CommandList.PropertyChanged -= this.undoListChanged;
            }
            ApplicationState.Instance.CommandList = new CommandList();
            ApplicationState.Instance.CommandList.PropertyChanged += this.undoListChanged;
        }
        private void calculateFrequencies()
        {
            if (!initializing && currentSong != null)
            {
                if (rbFreqMSX.Checked)
                {
                    tbParamFreq.Value = (int)LibAYEmu.ChipSpeedsByMachine.MSX;
                }

                if (rbFreqCPC.Checked)
                {
                    tbParamFreq.Value = (int)LibAYEmu.ChipSpeedsByMachine.CPC;
                }

                if (!rbCustom.Checked)
                {
                    Int16[] frequencies = NoteFileLoader.LoadDefaultNotes();
                    double  factor      = 1.0;
                    if (rbFreqCPC.Checked)
                    {
                        factor = (double)LibAYEmu.ChipSpeedsByMachine.CPC / (double)LibAYEmu.ChipSpeedsByMachine.MSX;
                    }
                    if (rbFreqSlider.Checked)
                    {
                        factor = (double)tbParamFreq.Value / (double)LibAYEmu.ChipSpeedsByMachine.MSX;
                    }
                    for (int i = 0; i < frequencies.Length; i++)
                    {
                        long newVal = (long)Math.Round(frequencies[i] * factor);
                        frequencies[i] = (newVal > Int16.MaxValue) ? Int16.MaxValue : newVal < Int16.MinValue ? Int16.MinValue : (Int16)newVal;
                    }
                    currentSong.Frequencies = frequencies;
                }
                gridNotas.ReadOnly  = !(rbCustom.Checked);
                tbParamFreq.Enabled = rbFreqSlider.Checked;
                saveLastSelectedValues();
                initializeBindingSource();
            }
        }