コード例 #1
0
ファイル: ExportDialog.cs プロジェクト: BleuBleu/FamiStudio
        private void ExportFamiTone2Music(bool famiStudio)
        {
            var props           = dialog.GetPropertyPage(famiStudio ? (int)ExportFormat.FamiStudioMusic : (int)ExportFormat.FamiTone2Music);
            var separate        = props.GetPropertyValue <bool>(1);
            var songIds         = GetSongIds(props.GetPropertyValue <bool[]>(5));
            var kernel          = famiStudio ? FamiToneKernel.FamiStudio : FamiToneKernel.FamiTone2;
            var exportFormat    = AssemblyFormat.GetValueForName(props.GetPropertyValue <string>(0));
            var ext             = exportFormat == AssemblyFormat.CA65 ? "s" : "asm";
            var songNamePattern = props.GetPropertyValue <string>(2);
            var dpcmNamePattern = props.GetPropertyValue <string>(3);
            var generateInclude = props.GetPropertyValue <bool>(4);

            if (separate)
            {
                var folder = lastExportFilename != null ? lastExportFilename : PlatformUtils.ShowBrowseFolderDialog("Select the export folder", ref Settings.LastExportFolder);

                if (folder != null)
                {
                    foreach (var songId in songIds)
                    {
                        var song = project.GetSong(songId);
                        var formattedSongName = songNamePattern.Replace("{project}", project.Name).Replace("{song}", song.Name);
                        var formattedDpcmName = dpcmNamePattern.Replace("{project}", project.Name).Replace("{song}", song.Name);
                        var songFilename      = Path.Combine(folder, Utils.MakeNiceAsmName(formattedSongName) + "." + ext);
                        var dpcmFilename      = Path.Combine(folder, Utils.MakeNiceAsmName(formattedDpcmName) + ".dmc");
                        var includeFilename   = generateInclude ? Path.ChangeExtension(songFilename, null) + "_songlist.inc" : null;

                        Log.LogMessage(LogSeverity.Info, $"Exporting song '{song.Name}' as separate assembly files.");

                        FamitoneMusicFile f = new FamitoneMusicFile(kernel, true);
                        f.Save(project, new int[] { songId }, exportFormat, true, songFilename, dpcmFilename, includeFilename, MachineType.Dual);
                    }

                    lastExportFilename = folder;
                }
            }
            else
            {
                var engineName = famiStudio ? "FamiStudio" : "FamiTone2";
                var filename   = lastExportFilename != null ? lastExportFilename : PlatformUtils.ShowSaveFileDialog($"Export {engineName} Assembly Code", $"{engineName} Assembly File (*.{ext})|*.{ext}", ref Settings.LastExportFolder);
                if (filename != null)
                {
                    var includeFilename = generateInclude ? Path.ChangeExtension(filename, null) + "_songlist.inc" : null;

                    Log.LogMessage(LogSeverity.Info, $"Exporting all songs to a single assembly file.");

                    FamitoneMusicFile f = new FamitoneMusicFile(kernel, true);
                    f.Save(project, songIds, exportFormat, false, filename, Path.ChangeExtension(filename, ".dmc"), includeFilename, MachineType.Dual);

                    lastExportFilename = filename;
                }
            }
        }
コード例 #2
0
ファイル: ExportDialog.cs プロジェクト: BleuBleu/FamiStudio
        private void ExportWavMp3()
        {
            var props  = dialog.GetPropertyPage((int)ExportFormat.WavMp3);
            var format = props.GetPropertyValue <string>(1);

            var filename = "";

            if (format == "MP3")
            {
                filename = lastExportFilename != null ? lastExportFilename : PlatformUtils.ShowSaveFileDialog("Export MP3 File", "MP3 Audio File (*.mp3)|*.mp3", ref Settings.LastExportFolder);
            }
            else
            {
                filename = lastExportFilename != null ? lastExportFilename : PlatformUtils.ShowSaveFileDialog("Export Wave File", "Wave Audio File (*.wav)|*.wav", ref Settings.LastExportFolder);
            }

            if (filename != null)
            {
                var songName         = props.GetPropertyValue <string>(0);
                var sampleRate       = Convert.ToInt32(props.GetPropertyValue <string>(2), CultureInfo.InvariantCulture);
                var bitRate          = Convert.ToInt32(props.GetPropertyValue <string>(3), CultureInfo.InvariantCulture);
                var loopCount        = props.GetPropertyValue <string>(4) != "Duration" ? props.GetPropertyValue <int>(5) : -1;
                var duration         = props.GetPropertyValue <string>(4) == "Duration" ? props.GetPropertyValue <int>(6) : -1;
                var separateFiles    = props.GetPropertyValue <bool>(7);
                var separateIntro    = props.GetPropertyValue <bool>(8);
                var selectedChannels = props.GetPropertyValue <bool[]>(9);
                var song             = project.GetSong(songName);

                var channelMask = 0;
                for (int i = 0; i < selectedChannels.Length; i++)
                {
                    if (selectedChannels[i])
                    {
                        channelMask |= (1 << i);
                    }
                }

                WavMp3ExportUtils.Save(song, filename, sampleRate, loopCount, duration, channelMask, separateFiles, separateIntro,
                                       (samples, fn) =>
                {
                    if (format == "MP3")
                    {
                        Mp3File.Save(samples, fn, sampleRate, bitRate);
                    }
                    else
                    {
                        WaveFile.Save(samples, fn, sampleRate);
                    }
                });

                lastExportFilename = filename;
            }
        }
コード例 #3
0
ファイル: ExportDialog.cs プロジェクト: MassVOiD/FamiStudio
        private void ExportText()
        {
            var filename = lastExportFilename != null ? lastExportFilename : PlatformUtils.ShowSaveFileDialog("Export FamiStudio Text File", "FamiStudio Text Export (*.txt)|*.txt", ref Settings.LastExportFolder);

            if (filename != null)
            {
                var props            = dialog.GetPropertyPage((int)ExportFormat.Text);
                var deleteUnusedData = props.GetPropertyValue <bool>(1);
                new FamistudioTextFile().Save(project, filename, GetSongIds(props.GetPropertyValue <bool[]>(0)), deleteUnusedData);
                lastExportFilename = filename;
            }
        }
コード例 #4
0
        private void ExportWav()
        {
            var filename = PlatformUtils.ShowSaveFileDialog("Export Wave File", "Wave Audio File (*.wav)|*.wav");

            if (filename != null)
            {
                var props      = dialog.GetPropertyPage((int)ExportFormat.Wav);
                var songName   = props.GetPropertyValue <string>(0);
                var sampleRate = Convert.ToInt32(props.GetPropertyValue <string>(1));

                WaveFile.Save(project.GetSong(songName), filename, sampleRate);
            }
        }
コード例 #5
0
ファイル: MobilePiano.cs プロジェクト: MassVOiD/FamiStudio
        protected override void OnRenderInitialized(RenderGraphics g)
        {
            Debug.Assert((int)ButtonImageIndices.Count == ButtonImageNames.Length);

            var screenSize = PlatformUtils.GetScreenResolution();

            layoutSize = Math.Min(screenSize.Width, screenSize.Height) / 4;

            bmpButtonAtlas       = g.CreateBitmapAtlasFromResources(ButtonImageNames);
            whiteKeyBrush        = g.CreateVerticalGradientBrush(0, layoutSize, Theme.LightGreyFillColor1, Theme.LightGreyFillColor2);
            blackKeyBrush        = g.CreateVerticalGradientBrush(0, layoutSize, Theme.DarkGreyFillColor1, Theme.DarkGreyFillColor2);
            whiteKeyPressedBrush = g.CreateVerticalGradientBrush(0, layoutSize, Theme.Darken(Theme.LightGreyFillColor1), Theme.Darken(Theme.LightGreyFillColor2));
            blackKeyPressedBrush = g.CreateVerticalGradientBrush(0, layoutSize, Theme.Lighten(Theme.DarkGreyFillColor1), Theme.Lighten(Theme.DarkGreyFillColor2));
        }
コード例 #6
0
ファイル: ProjectExplorer.cs プロジェクト: VN0/FamiStudio
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);

            if (isDraggingInstrument)
            {
                if (ClientRectangle.Contains(e.X, e.Y))
                {
                    var buttonIdx = GetButtonAtCoord(e.X, e.Y, out var subButtonType);

                    var instrumentSrc = instrumentDrag;
                    var instrumentDst = buttonIdx >= 0 && buttons[buttonIdx].type == ButtonType.Instrument ? buttons[buttonIdx].instrument : null;

                    if (instrumentSrc != instrumentDst && instrumentSrc != null && instrumentDst != null && instrumentSrc.ExpansionType == instrumentDst.ExpansionType)
                    {
                        if (envelopeDragIdx == -1)
                        {
                            if (PlatformUtils.MessageBox($"Are you sure you want to replace all notes of instrument '{instrumentDst.Name}' with '{instrumentSrc.Name}'?", "Replace intrument", MessageBoxButtons.YesNo) == DialogResult.Yes)
                            {
                                App.UndoRedoManager.BeginTransaction(TransactionScope.Project);
                                App.Project.ReplaceInstrument(instrumentDst, instrumentSrc);
                                App.UndoRedoManager.EndTransaction();

                                InstrumentReplaced?.Invoke(instrumentDst);
                            }
                        }
                        else
                        {
                            if (PlatformUtils.MessageBox($"Are you sure you want to copy the {Envelope.EnvelopeStrings[envelopeDragIdx]} envelope of instrument '{instrumentSrc.Name}' to '{instrumentDst.Name}'?", "Copy Envelope", MessageBoxButtons.YesNo) == DialogResult.Yes)
                            {
                                App.UndoRedoManager.BeginTransaction(TransactionScope.Instrument, instrumentDst.Id);
                                instrumentDst.Envelopes[envelopeDragIdx] = instrumentSrc.Envelopes[envelopeDragIdx].Clone();
                                App.UndoRedoManager.EndTransaction();

                                InstrumentEdited?.Invoke(instrumentDst, envelopeDragIdx);
                                Invalidate();
                            }
                        }
                    }
                }
                else
                {
                    InstrumentDraggedOutside(instrumentDrag, PointToScreen(new Point(e.X, e.Y)));
                }

                Capture = false;
            }

            CancelDrag();
        }
コード例 #7
0
        public static void SaveEnvelopeValues(sbyte[] values)
        {
            var clipboardData = new List <byte>();

            clipboardData.AddRange(BitConverter.GetBytes(MagicNumberClipboardEnvelope));
            clipboardData.AddRange(BitConverter.GetBytes(values.Length));
            for (int i = 0; i < values.Length; i++)
            {
                clipboardData.Add((byte)values[i]);
            }

            PlatformUtils.ClearClipboardString();
            PlatformUtils.SetClipboardData(clipboardData.ToArray());
        }
コード例 #8
0
        public void StopImmediate()
        {
            Debug.Assert(PlatformUtils.IsInMainThread());

            if (immediateStream != IntPtr.Zero)
            {
                Pa_AbortStream(immediateStream);
                //Pa_StopStream(immediateStream);
                Pa_CloseStream(immediateStream);
                immediateStream         = IntPtr.Zero;
                immediateStreamData     = null;
                immediateStreamPosition = -1;
            }
        }
コード例 #9
0
ファイル: MobilePiano.cs プロジェクト: MassVOiD/FamiStudio
        protected void PlayPiano(int x, int y)
        {
            var note = GetPianoNote(x, y);

            if (note >= 0)
            {
                if (note != playAbsNote)
                {
                    playAbsNote = note;
                    App.PlayInstrumentNote(playAbsNote, true, true);
                    PlatformUtils.VibrateTick();
                    MarkDirty();
                }
            }
        }
コード例 #10
0
ファイル: OpenALStream.cs プロジェクト: MassVOiD/FamiStudio
        public void StopImmediate()
        {
            Debug.Assert(PlatformUtils.IsInMainThread());

            if (immediateSource >= 0)
            {
                AL.SourceStop(immediateSource);
                AL.Source(immediateSource, ALSourcei.Buffer, 0);
                AL.DeleteBuffers(immediateBuffers);
                AL.DeleteSource(immediateSource);

                immediateBuffers = null;
                immediateSource  = -1;
            }
        }
コード例 #11
0
ファイル: DpiScaling.cs プロジェクト: MassVOiD/FamiStudio
        public static void Initialize()
        {
            if (PlatformUtils.IsMobile)
            {
                var density = PlatformUtils.GetPixelDensity();

                if (Settings.DpiScaling != 0)
                {
                    mainWindowScaling = Settings.DpiScaling / 100.0f;
                }
                else
                {
                    if (density < 360)
                    {
                        mainWindowScaling = 0.666f;
                    }
                    else if (density >= 480)
                    {
                        mainWindowScaling = 1.333f;
                    }
                    else
                    {
                        mainWindowScaling = 1.0f;
                    }
                }

                dialogScaling     = 1;
                fontScaling       = (float)Math.Round(mainWindowScaling * 3);
                mainWindowScaling = (float)Math.Round(mainWindowScaling * 6);
            }
            else
            {
                dialogScaling = PlatformUtils.GetDesktopScaling();

                if (Settings.DpiScaling != 0)
                {
                    mainWindowScaling = RoundScaling(Settings.DpiScaling / 100.0f);
                }
                else
                {
                    mainWindowScaling = RoundScaling(dialogScaling);
                }

                fontScaling = mainWindowScaling;
            }

            initialized = true;
        }
コード例 #12
0
        private void ExportFamiTone2Sfx(bool famiStudio)
        {
            var props        = dialog.GetPropertyPage(famiStudio ? (int)ExportFormat.FamiStudioSfx : (int)ExportFormat.FamiTone2Sfx);
            var exportFormat = (AssemblyFormat)Enum.Parse(typeof(AssemblyFormat), props.GetPropertyValue <string>(0));
            var ext          = exportFormat == AssemblyFormat.CA65 ? "s" : "asm";
            var mode         = (MachineType)Enum.Parse(typeof(MachineType), props.GetPropertyValue <string>(1));
            var songIds      = GetSongIds(props.GetPropertyValue <bool[]>(2));

            var filename = PlatformUtils.ShowSaveFileDialog("Export FamiTone2 Code", $"FamiTone2 Assembly File (*.{ext})|*.{ext}", ref Settings.LastExportFolder);

            if (filename != null)
            {
                FamitoneSoundEffectFile f = new FamitoneSoundEffectFile();
                f.Save(project, songIds, exportFormat, mode, filename);
            }
        }
コード例 #13
0
        private void ExportNsf()
        {
            var filename = PlatformUtils.ShowSaveFileDialog("Export NSF File", "Nintendo Sound Files (*.nsf)|*.nsf");

            if (filename != null)
            {
                var props  = dialog.GetPropertyPage((int)ExportFormat.Nsf);
                var kernel = (FamitoneMusicFile.FamiToneKernel)Enum.Parse(typeof(FamitoneMusicFile.FamiToneKernel), props.GetPropertyValue <string>(5));

                NsfFile.Save(project, kernel, filename,
                             GetSongIds(props.GetPropertyValue <bool[]>(4)),
                             props.GetPropertyValue <string>(0),
                             props.GetPropertyValue <string>(1),
                             props.GetPropertyValue <string>(2));
            }
        }
コード例 #14
0
ファイル: MobilePiano.cs プロジェクト: MassVOiD/FamiStudio
        private void UpdateRenderCoords()
        {
            var screenSize = PlatformUtils.GetScreenResolution();
            var scale      = Math.Min(screenSize.Width, screenSize.Height) / 1080.0f;

            whiteKeySizeX = ScaleCustom(DefaultWhiteKeySizeX, scale * zoom);
            blackKeySizeX = ScaleCustom(DefaultBlackKeySizeX, scale * zoom);
            octaveSizeX   = 7 * whiteKeySizeX;
            virtualSizeX  = octaveSizeX * NumOctaves;

            // Center the piano initially.
            if (scrollX < 0)
            {
                scrollX = (virtualSizeX - Width) / 2;
            }
        }
コード例 #15
0
ファイル: OpenALStream.cs プロジェクト: MassVOiD/FamiStudio
        public unsafe void PlayImmediate(short[] data, int sampleRate, float volume)
        {
            Debug.Assert(PlatformUtils.IsInMainThread());

            StopImmediate();

            immediateSource  = AL.GenSource();
            immediateBuffers = AL.GenBuffers(1);

            fixed(short *p = &data[0])
            AL.BufferData(immediateBuffers[0], ALFormat.Mono16, new IntPtr(p), data.Length * sizeof(short), sampleRate);

            AL.Source(immediateSource, ALSourcef.Gain, volume);
            AL.SourceQueueBuffer(immediateSource, immediateBuffers[0]);
            AL.SourcePlay(immediateSource);
        }
コード例 #16
0
ファイル: ExportDialog.cs プロジェクト: MassVOiD/FamiStudio
        private void ExportFamiTracker()
        {
            if (!canExportToFamiTracker)
            {
                return;
            }

            var props = dialog.GetPropertyPage((int)ExportFormat.FamiTracker);

            var filename = lastExportFilename != null ? lastExportFilename : PlatformUtils.ShowSaveFileDialog("Export FamiTracker Text File", "FamiTracker Text Format (*.txt)|*.txt", ref Settings.LastExportFolder);

            if (filename != null)
            {
                new FamitrackerTextFile().Save(project, filename, GetSongIds(props.GetPropertyValue <bool[]>(0)));
                lastExportFilename = filename;
            }
        }
コード例 #17
0
        public void Paste()
        {
            if (!IsSelectionValid())
            {
                return;
            }

            var mergeInstruments = ClipboardUtils.ContainsMissingInstruments(App.Project, false);

            bool createMissingInstrument = false;

            if (mergeInstruments)
            {
                createMissingInstrument = PlatformUtils.MessageBox($"You are pasting notes referring to unknown instruments. Do you want to create the missing instrument?", "Paste", MessageBoxButtons.YesNo) == DialogResult.Yes;
            }

            App.UndoRedoManager.BeginTransaction(createMissingInstrument ? TransactionScope.Project : TransactionScope.Song, Song.Id);

            var patterns = ClipboardUtils.LoadPatterns(App.Project, Song, createMissingInstrument);

            if (patterns == null)
            {
                App.UndoRedoManager.AbortTransaction();
                return;
            }

            for (int i = 0; i < patterns.GetLength(0); i++)
            {
                for (int j = 0; j < patterns.GetLength(1); j++)
                {
                    var pattern = patterns[i, j];

                    if (pattern != null && (i + minSelectedPatternIdx) < Song.Length &&
                        pattern.ChannelType < Song.Channels.Length &&
                        pattern.ChannelType == Song.Channels[pattern.ChannelType].Type)
                    {
                        Song.Channels[pattern.ChannelType].PatternInstances[i + minSelectedPatternIdx] = pattern;
                    }
                }
            }

            App.UndoRedoManager.EndTransaction();
            PatternsPasted?.Invoke();
            ConditionalInvalidate();
        }
コード例 #18
0
ファイル: ConfigDialog.cs プロジェクト: jroweboy/FamiStudio
        void QwertyListDoubleClicked(PropertyPage props, int propertyIndex, int itemIndex, int columnIndex)
        {
            if (columnIndex < 2)
            {
                return;
            }

            var dlg = new PropertyDialog(300, false, true, dialog);

            dlg.Properties.AddLabel(null, "Press the new key or ESC to cancel.");
            dlg.Properties.Build();

            // TODO : Make this cross-platform.
#if FAMISTUDIO_WINDOWS
            dlg.KeyDown += (sender, e) =>
            {
                if (PlatformUtils.KeyCodeToString((int)e.KeyCode) != null)
                {
                    if (e.KeyCode != Keys.Escape)
                    {
                        AssignQwertyKey(itemIndex, columnIndex - 2, (int)e.KeyCode);
                    }
                    dlg.Close();
                }
            };
#else
            dlg.KeyPressEvent += (o, args) =>
            {
                // These 2 keys are used by the QWERTY input.
                if (args.Event.Key != Gdk.Key.Tab &&
                    args.Event.Key != Gdk.Key.BackSpace &&
                    PlatformUtils.KeyCodeToString((int)args.Event.Key) != null)
                {
                    if (args.Event.Key != Gdk.Key.Escape)
                    {
                        AssignQwertyKey(itemIndex, columnIndex - 2, (int)args.Event.Key);
                    }
                    dlg.Accept();
                }
            };
#endif
            dlg.ShowDialog(null);

            pages[(int)ConfigSection.QWERTY].UpdateMultiColumnList(1, GetQwertyMappingStrings());
        }
コード例 #19
0
ファイル: XAudio2Stream.cs プロジェクト: MassVOiD/FamiStudio
        public void StopImmediate()
        {
            Debug.Assert(PlatformUtils.IsInMainThread());

            if (immediateVoice != null)
            {
                immediateVoice.Stop();
                immediateVoice.FlushSourceBuffers();
                immediateVoice.BufferEnd -= ImmediateVoice_BufferEnd;
                immediateVoice.DestroyVoice();
                immediateVoice.Dispose();
                immediateVoice = null;

                Utilities.FreeMemory(immediateAudioBuffer.AudioDataPointer);
                immediateAudioBuffer = null;
                immediateDonePlaying = true;
            }
        }
コード例 #20
0
ファイル: ExportDialog.cs プロジェクト: BleuBleu/FamiStudio
        private void ExportMidi()
        {
            var filename = lastExportFilename != null ? lastExportFilename : PlatformUtils.ShowSaveFileDialog("Export MIDI File", "MIDI Files (*.mid)|*.mid", ref Settings.LastExportFolder);

            if (filename != null)
            {
                var props          = dialog.GetPropertyPage((int)ExportFormat.Midi);
                var songName       = props.GetPropertyValue <string>(0);
                var velocity       = props.GetPropertyValue <bool>(1);
                var slideNotes     = props.GetPropertyValue <bool>(2);
                var pitchRange     = props.GetPropertyValue <int>(3);
                var instrumentMode = props.GetSelectedIndex(4);

                new MidiFileWriter().Save(project, filename, project.GetSong(songName).Id, instrumentMode, midiInstrumentMapping, velocity, slideNotes, pitchRange);

                lastExportFilename = filename;
            }
        }
コード例 #21
0
        static unsafe void Main(string[] args)
        {
#if FAMISTUDIO_WINDOWS
            try
            {
                // This is only supported in Windows 8.1+.
                SetProcessDpiAwareness(1 /*Process_System_DPI_Aware*/);
            }
            catch { }
#endif

            Settings.Load();
            RenderTheme.Initialize();
            PlatformUtils.Initialize();
            Cursors.Initialize();
            FamiStudioTempoUtils.Initialize();
            NesApu.InitializeNoteTables();

#if FAMISTUDIO_WINDOWS
            WinUtils.Initialize();
            PerformanceCounter.Initialize();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
#endif
#if FAMISTUDIO_LINUX
            LinuxUtils.SetProcessName("FamiStudio");
#endif

            var cli = new CommandLineInterface(args);

            if (!cli.Run())
            {
                var famiStudio = new FamiStudio(args.Length > 0 ? args[0] : null);
                famiStudio.Run();
            }

            Settings.Save();

#if FAMISTUDIO_LINUX
            // We sometimes gets stuck here on Linux, lets abort.
            Environment.Exit(0);
#endif
        }
コード例 #22
0
        private void ExportFamiTone2()
        {
            var props           = dialog.GetPropertyPage((int)ExportFormat.FamiTone2);
            var kernelString    = props.GetPropertyValue <string>(0);
            var formatString    = props.GetPropertyValue <string>(1);
            var ext             = formatString == "CA65" ? "s" : "asm";
            var separate        = props.GetPropertyValue <bool>(2);
            var songIds         = GetSongIds(props.GetPropertyValue <bool[]>(5));
            var kernel          = (FamitoneMusicFile.FamiToneKernel)Enum.Parse(typeof(FamitoneMusicFile.FamiToneKernel), kernelString);
            var exportFormat    = (FamitoneMusicFile.OutputFormat)Enum.Parse(typeof(FamitoneMusicFile.OutputFormat), formatString);
            var songNamePattern = props.GetPropertyValue <string>(3);
            var dpcmNamePattern = props.GetPropertyValue <string>(4);

            if (separate)
            {
                var folderBrowserDialog = new FolderBrowserDialog();
                folderBrowserDialog.Description = "Select the export folder";

                if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
                {
                    foreach (var songId in songIds)
                    {
                        var song = project.GetSong(songId);
                        var formattedSongName = songNamePattern.Replace("{project}", project.Name).Replace("{song}", song.Name);
                        var formattedDpcmName = dpcmNamePattern.Replace("{project}", project.Name).Replace("{song}", song.Name);
                        var songFilename      = Path.Combine(folderBrowserDialog.SelectedPath, Utils.MakeNiceAsmName(formattedSongName) + "." + ext);
                        var dpcmFilename      = Path.Combine(folderBrowserDialog.SelectedPath, Utils.MakeNiceAsmName(formattedDpcmName) + ".dmc");

                        FamitoneMusicFile f = new FamitoneMusicFile(kernel);
                        f.Save(project, new int[] { songId }, exportFormat, true, songFilename, dpcmFilename, MachineType.Dual);
                    }
                }
            }
            else
            {
                var filename = PlatformUtils.ShowSaveFileDialog("Export FamiTone2 Code", $"FamiTone2 Assembly File (*.{ext})|*.{ext}");
                if (filename != null)
                {
                    FamitoneMusicFile f = new FamitoneMusicFile(kernel);
                    f.Save(project, songIds, exportFormat, false, filename, Path.ChangeExtension(filename, ".dmc"), MachineType.Dual);
                }
            }
        }
コード例 #23
0
        private void Properties_PropertyClicked(PropertyPage props, ClickType click, int propIdx, int rowIdx, int colIdx)
        {
            if (click == ClickType.Button && colIdx == 2)
            {
                var src = channelSources[rowIdx];

                if (src.type == MidiSourceType.Channel && src.index == 9)
                {
                    var dlg = new PropertyDialog("MIDI Source", 300, true, true, dialog);
                    dlg.Properties.AddLabel(null, "Channel 10 keys:");                                                    // 0
                    dlg.Properties.AddCheckBoxList(null, MidiFileReader.MidiDrumKeyNames, GetSelectedChannel10Keys(src)); // 1
                    dlg.Properties.AddButton(null, "Select All");                                                         // 2
                    dlg.Properties.AddButton(null, "Select None");                                                        // 3
                    dlg.Properties.Build();
                    dlg.Properties.PropertyClicked += MappingProperties_PropertyClicked;

                    dlg.ShowDialogAsync(null, (r) =>
                    {
                        if (r == DialogResult.OK)
                        {
                            var keysBool = dlg.Properties.GetPropertyValue <bool[]>(1);

                            src.keys = 0ul;
                            for (int i = 0; i < keysBool.Length; i++)
                            {
                                if (keysBool[i])
                                {
                                    src.keys |= (1ul << i);
                                }
                            }

                            UpdateListView();
                        }
                    });
                }
                else
                {
                    PlatformUtils.Beep();
                }
            }
        }
コード例 #24
0
ファイル: ExportDialog.cs プロジェクト: LevelASMer/FamiStudio
        private void ExportRom()
        {
            var props   = dialog.GetPropertyPage((int)ExportFormat.Rom);
            var songIds = GetSongIds(props.GetPropertyValue <bool[]>(4));

            if (songIds.Length > RomFileBase.MaxSongs)
            {
                PlatformUtils.MessageBox($"Please select {RomFileBase.MaxSongs} songs or less.", "ROM Export", MessageBoxButtons.OK);
                return;
            }

            if (props.GetPropertyValue <string>(0) == "NES ROM")
            {
                var filename = lastExportFilename != null ? lastExportFilename : PlatformUtils.ShowSaveFileDialog("Export ROM File", "NES ROM (*.nes)|*.nes", ref Settings.LastExportFolder);
                if (filename != null)
                {
                    var rom = new RomFile();
                    rom.Save(
                        project, filename, songIds,
                        props.GetPropertyValue <string>(1),
                        props.GetPropertyValue <string>(2),
                        props.GetPropertyValue <string>(3) == "PAL");

                    lastExportFilename = filename;
                }
            }
            else
            {
                var filename = lastExportFilename != null ? null : PlatformUtils.ShowSaveFileDialog("Export Famicom Disk", "FDS Disk (*.fds)|*.fds", ref Settings.LastExportFolder);
                if (filename != null)
                {
                    var fds = new FdsFile();
                    fds.Save(
                        project, filename, songIds,
                        props.GetPropertyValue <string>(1),
                        props.GetPropertyValue <string>(2));

                    lastExportFilename = filename;
                }
            }
        }
コード例 #25
0
ファイル: ExportDialog.cs プロジェクト: LevelASMer/FamiStudio
        private void ExportFamiTone2Sfx(bool famiStudio)
        {
            var props           = dialog.GetPropertyPage(famiStudio ? (int)ExportFormat.FamiStudioSfx : (int)ExportFormat.FamiTone2Sfx);
            var exportFormat    = AssemblyFormat.GetValueForName(props.GetPropertyValue <string>(0));
            var ext             = exportFormat == AssemblyFormat.CA65 ? "s" : "asm";
            var mode            = MachineType.GetValueForName(props.GetPropertyValue <string>(1));
            var engineName      = famiStudio ? "FamiStudio" : "FamiTone2";
            var generateInclude = props.GetPropertyValue <bool>(2);
            var songIds         = GetSongIds(props.GetPropertyValue <bool[]>(3));

            var filename = lastExportFilename != null ? lastExportFilename : PlatformUtils.ShowSaveFileDialog($"Export {engineName} Code", $"{engineName} Assembly File (*.{ext})|*.{ext}", ref Settings.LastExportFolder);

            if (filename != null)
            {
                var includeFilename = generateInclude ? Path.ChangeExtension(filename, null) + "_sfxlist.inc" : null;

                FamitoneSoundEffectFile f = new FamitoneSoundEffectFile();
                f.Save(project, songIds, exportFormat, mode, famiStudio ? FamiToneKernel.FamiStudio : FamiToneKernel.FamiTone2, filename, includeFilename);
                lastExportFilename = filename;
            }
        }
コード例 #26
0
ファイル: ExportDialog.cs プロジェクト: BleuBleu/FamiStudio
        private void FFmpegPathButtonClicked(PropertyPage props, int propertyIndex)
        {
            var dummy = "";

#if FAMISTUDIO_WINDOWS
            var ffmpegExeFilter = "FFmpeg Executable (ffmpeg.exe)|ffmpeg.exe";
#else
            var ffmpegExeFilter = "FFmpeg Executable (ffmpeg)|*.*";
#endif

            string filename = PlatformUtils.ShowOpenFileDialog("Please select FFmpeg executable", ffmpegExeFilter, ref dummy, dialog);

            if (filename != null)
            {
                props.SetPropertyValue(propertyIndex, filename);

                // Update settings right away.
                Settings.FFmpegExecutablePath = filename;
                Settings.Save();
            }
        }
コード例 #27
0
ファイル: ConfigDialog.cs プロジェクト: MassVOiD/FamiStudio
        private void FFmpegPage_PropertyClicked(PropertyPage props, ClickType click, int propIdx, int rowIdx, int colIdx)
        {
            if (click == ClickType.Button)
            {
                if (propIdx == 1)
                {
                    var ffmpegExeFilter = PlatformUtils.IsWindows ? "FFmpeg Executable (ffmpeg.exe)|ffmpeg.exe" : "FFmpeg Executable (ffmpeg)|*.*";
                    var dummy           = "";
                    var filename        = PlatformUtils.ShowOpenFileDialog("Please select FFmpeg executable", ffmpegExeFilter, ref dummy, dialog);

                    if (filename != null)
                    {
                        props.SetPropertyValue(propIdx, filename);
                    }
                }
                else if (propIdx == 2)
                {
                    PlatformUtils.OpenUrl("https://famistudio.org/doc/ffmpeg/");
                }
            }
        }
コード例 #28
0
ファイル: GLESGraphics.cs プロジェクト: MassVOiD/FamiStudio
        protected Bitmap LoadBitmapFromResourceWithScaling(string name)
        {
            var assembly = Assembly.GetExecutingAssembly();

            Bitmap bmp;

            if (windowScaling >= 4.0f && assembly.GetManifestResourceInfo($"FamiStudio.Resources.{name}@4x.png") != null)
            {
                bmp = PlatformUtils.LoadBitmapFromResource($"FamiStudio.Resources.{name}@4x.png");
            }
            else if (windowScaling >= 2.0f && assembly.GetManifestResourceInfo($"FamiStudio.Resources.{name}@2x.png") != null)
            {
                bmp = PlatformUtils.LoadBitmapFromResource($"FamiStudio.Resources.{name}@2x.png");
            }
            else
            {
                bmp = PlatformUtils.LoadBitmapFromResource($"FamiStudio.Resources.{name}.png");
            }

            return(bmp);
        }
コード例 #29
0
        public System.Windows.Forms.DialogResult ShowDialog()
        {
            Show();
#if FAMISTUDIO_MACOS
            MacUtils.SetNSWindowAlwayOnTop(MacUtils.NSWindowFromGdkWindow(GdkWindow.Handle));
#endif

            while (result == System.Windows.Forms.DialogResult.None)
            {
                Application.RunIteration();
            }

            Hide();
#if FAMISTUDIO_MACOS
            MacUtils.RestoreMainNSWindowFocus();
#else
            PlatformUtils.ProcessPendingEvents();
#endif

            return(result);
        }
コード例 #30
0
ファイル: XAudio2Stream.cs プロジェクト: MassVOiD/FamiStudio
        public void PlayImmediate(short[] data, int sampleRate, float volume)
        {
            Debug.Assert(PlatformUtils.IsInMainThread());

            StopImmediate();

            immediateDonePlaying = false;

            immediateAudioBuffer = new AudioBuffer();
            immediateAudioBuffer.AudioDataPointer = Utilities.AllocateMemory(data.Length * sizeof(short));
            immediateAudioBuffer.AudioBytes       = data.Length * sizeof(short);
            Marshal.Copy(data, 0, immediateAudioBuffer.AudioDataPointer, data.Length);

            var waveFormat = new WaveFormat(sampleRate, 16, 1);

            immediateVoice            = new SourceVoice(xaudio2, waveFormat);
            immediateVoice.BufferEnd += ImmediateVoice_BufferEnd;
            immediateVoice.SetVolume(volume);
            immediateVoice.SubmitSourceBuffer(immediateAudioBuffer, null);
            immediateVoice.Start();
        }