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; } }
private void SerializeMusicChip(MusicChip musicChip) { JsonUtil.GetLineBreak(sb); sb.Append("\"MusicChip\":"); JsonUtil.GetLineBreak(sb); sb.Append("{"); JsonUtil.GetLineBreak(sb, 1); sb.Append("\"totalTracks\":"); sb.Append(musicChip.totalTracks); sb.Append(","); JsonUtil.GetLineBreak(sb, 1); sb.Append("\"notesPerTrack\":"); sb.Append(musicChip.maxNoteNum); sb.Append(","); JsonUtil.GetLineBreak(sb, 1); sb.Append("\"totalLoop\":"); sb.Append(musicChip.totalLoops); JsonUtil.GetLineBreak(sb); sb.Append("}"); sb.Append(","); currentStep++; }
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)); }
static MusicChip[] CreateMusicChips() { var chips = new MusicChip[2]; for (int i = 0; i < chips.Length; i++) { chips[i] = new MusicChip(); } return(chips); }
// 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; }
// 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(); } }
private void SerializeMusicChip(MusicChip musicChip) { JsonUtil.GetLineBreak(sb); sb.Append("\"MusicChip\":"); JsonUtil.GetLineBreak(sb); sb.Append("{"); JsonUtil.GetLineBreak(sb, 1); // sb.Append("\"totalTracks\":"); // sb.Append(musicChip.totalTracks); // sb.Append(","); // JsonUtil.GetLineBreak(sb, 1); sb.Append("\"totalSongs\":"); sb.Append(musicChip.totalSongs); sb.Append(","); JsonUtil.GetLineBreak(sb, 1); sb.Append("\"notesPerTrack\":"); sb.Append(musicChip.maxNoteNum); sb.Append(","); JsonUtil.GetLineBreak(sb, 1); sb.Append("\"totalPatterns\":"); sb.Append(musicChip.TotalLoops); sb.Append(","); JsonUtil.GetLineBreak(sb, 1); // TODO legacy property sb.Append("\"totalLoop\":"); sb.Append(musicChip.TotalLoops); JsonUtil.GetLineBreak(sb); sb.Append("}"); sb.Append(","); currentStep++; }
static MusicChip[] CreateMusicChips() { var chips = new MusicChip[2]; for (int i = 0; i < chips.Length; i++) { chips[i] = new MusicChip(); } return chips; }