public void ExportPattern(WorkspacePath filePath, MusicChip musicChip, SoundChip soundChip, int id)
        {
            var selectedPatterns = new int[id];

            if (!Exists(filePath))
            {
                CreateDirectory(filePath);
            }

            try
            {
                filePath = UniqueFilePath(filePath.AppendFile("pattern+" + id + ".wav"));


                // TODO exporting sprites doesn't work
                if (locator.GetService(typeof(ExportService).FullName) is ExportService exportService)
                {
                    exportService.ExportSong(filePath.Path, musicChip, soundChip, selectedPatterns);
                    //
                    exportService.StartExport();
                }
            }
            catch (Exception e)
            {
                // TODO this needs to go through the error system?
                Console.WriteLine(e);
                throw;
            }
        }
Exemple #2
0
        public void ExportSong(string path, MusicChip musicChip, SoundChip soundChip, int[] patterns)
        {
            Reset();

            // TODO this should just use the active engine?
//            var name = targetEngine.musicChip.activeSongData.songName;
//            UnityEngine.Debug.Log("Export Song " + path);
            // TODO need to add a base path to the file name so we can create folders.
            AddExporter(new SongExporter(path, musicChip, soundChip, patterns));
        }
        //        int songdataCurrentPos = 0;

        public SongExporter(string path, MusicChip musicChip, SoundChip soundChip, int[] patterns) : base(path)
        {
            // Rebuild the path by adding the active song name and wav extension
            fileName = path;

            // Save references to the currentc chips
            this.musicChip = musicChip;
            this.soundChip = soundChip;

            this.patterns = patterns;
        }
Exemple #4
0
        static void DumpChip(SoundChip chip, int number)
        {
            var info = chip.GetInfo();

            Console.WriteLine("\t\t#{0} [{1}] ----------", number, info.Name);
            Console.WriteLine("\t\tType: {0} ({1} Hz)", info.Type, info.Clock);
            Console.WriteLine("\t\tSlot: {0}", info.Slot);
            Console.WriteLine("\t\tLocation: {0}", info.SoundLocation);

            var compatible = info.CompatibleChipType.Zip(info.CompatibleChipClock, (t, c) => string.Format("{0} ({1} Hz)", t, c));
            Console.WriteLine("\t\tCompatible: {0}", string.Join(", ", compatible));
            Console.WriteLine("\t\tUsed: {0}", info.IsUsed);

            Console.WriteLine();
        }
Exemple #5
0
        private static void DumpChip(SoundChip chip, int number)
        {
            var info = chip.GetInfo();

            Console.WriteLine("\t\t#{0} [{1}] ----------", number, info.Name);
            Console.WriteLine("\t\tType: {0} ({1} Hz)", info.Type, info.Clock);
            Console.WriteLine("\t\tSlot: {0}", info.Slot);
            Console.WriteLine("\t\tLocation: {0}", info.SoundLocation);

            var compatible = info.CompatibleChipType.Zip(info.CompatibleChipClock, (t, c) => $"{t} ({c} Hz)");

            Console.WriteLine("\t\tCompatible: {0}", string.Join(", ", compatible));
            Console.WriteLine("\t\tUsed: {0}", info.IsUsed);

            Console.WriteLine();
        }
        // Exports the active song in the music chip
        public void ExportSong(string path, MusicChip musicChip, SoundChip soundChip, int id)
        {
            var currentSong = musicChip.songs[id];

            var selectedPatterns = new int[currentSong.end];

            Array.Copy(currentSong.patterns, selectedPatterns, selectedPatterns.Length);

            var filePath = WorkspacePath.Parse(path);

            if (Exists(filePath))
            {
                filePath = filePath.AppendDirectory("Wavs").AppendDirectory("Songs");

                if (!Exists(filePath))
                {
                    CreateDirectory(filePath);
                }

                try
                {
                    filePath = UniqueFilePath(filePath.AppendFile("song " + id + " - " + currentSong.name + ".wav"));

                    Console.WriteLine("Export song to " + filePath);


                    // TODO exporting sprites doesn't work
                    if (locator.GetService(typeof(ExportService).FullName) is ExportService exportService)
                    {
                        exportService.ExportSong(filePath.Path, musicChip, soundChip, selectedPatterns);
                        //
                        exportService.StartExport();
                    }
                }
                catch (Exception e)
                {
                    // TODO this needs to go through the error system?
                    Console.WriteLine(e);
                    throw;
                }

                // TODO saving song doesn't work
//                runner.exportService.ExportSong(filePath.Path, musicChip, soundChip);
//
//                runner.StartExport();
            }
        }
Exemple #7
0
        private void SerializeSoundChip(SoundChip soundChip)
        {
            JsonUtil.GetLineBreak(sb);
            sb.Append("\"SoundChip\":");

            JsonUtil.GetLineBreak(sb);
            sb.Append("{");
            JsonUtil.GetLineBreak(sb, 1);

            sb.Append("\"totalChannels\":");
            sb.Append(soundChip.totalChannels);
            sb.Append(",");
            JsonUtil.GetLineBreak(sb, 1);

            sb.Append("\"totalSounds\":");
            sb.Append(soundChip.totalSounds);
            sb.Append(",");
            JsonUtil.GetLineBreak(sb, 1);

            sb.Append("\"channelTypes\":[");

            var total = soundChip.totalChannels;

            for (var i = 0; i < total; i++)
            {
//                Console.WriteLine("Channel "+i +" type "+soundChip.ChannelType(i));

                sb.Append((int)soundChip.ChannelType(i));
                if (i < total - 1)
                {
                    sb.Append(",");
                }
            }

            sb.Append("]");

            JsonUtil.GetLineBreak(sb);
            sb.Append("}");
            sb.Append(",");

            currentStep++;
        }
Exemple #8
0
        private void SerializeSoundChip(SoundChip soundChip)
        {
            JsonUtil.GetLineBreak(sb);
            sb.Append("\"SoundChip\":");

            JsonUtil.GetLineBreak(sb);
            sb.Append("{");
            JsonUtil.GetLineBreak(sb, 1);

            sb.Append("\"totalChannels\":");
            sb.Append(soundChip.totalChannels);
            sb.Append(",");
            JsonUtil.GetLineBreak(sb, 1);

            sb.Append("\"totalSounds\":");
            sb.Append(soundChip.totalSounds);
//            sb.Append(",");

            JsonUtil.GetLineBreak(sb, 0);
            sb.Append("}");
            sb.Append(",");

            currentStep++;
        }
Exemple #9
0
 public WavParser(IEngine engine, Dictionary <string, byte[]> files)
 {
     soundChip  = engine.soundChip;
     this.files = files;
 }
Exemple #10
0
 public WavParser(string[] files, IFileLoadHelper fileLoadHelper, IEngine engine)
 {
     _fileLoadHelper = fileLoadHelper;
     soundChip       = engine.SoundChip;
     this.files      = files;
 }