public void Create(FormatData data, Stream audio, AudioFormat format) { data.SetStream(this, AudioName, audio); if (format != null) { Stream formatstream = data.AddStream(this, FormatName); format.Save(formatstream); data.CloseStream(formatstream); } }
public void Create(FormatData data, Stream[] streams, AudioFormat format) { Stream formatstream = data.AddStream(this, FormatName); format.Save(formatstream); data.CloseStream(formatstream); for (int i = 0; i < streams.Length; i++) { data.SetStream(this, AudioName + (i == 0 ? string.Empty : ("." + i.ToString())), streams[i]); } }
internal void EncodeOggAudio(AudioFormat data, FormatData destination, IFormat format, Stream stream, ProgressIndicator progress) { IDecoder decoder = data.Decoder; RawkAudio.Encoder encoder = new RawkAudio.Encoder(stream, decoder.Channels, decoder.SampleRate); AudioFormat.ProcessOffset(decoder, encoder, data.InitialOffset); progress.NewTask(1); AudioFormat.Transcode(encoder, decoder, progress); progress.Progress(); encoder.Dispose(); destination.CloseStream(format, AudioName); decoder.Dispose(); data.Save(destination.AddStream(format, FormatName)); destination.CloseStream(format, FormatName); progress.EndTask(); }
public override void EncodeAudio(AudioFormat audioformat, FormatData formatdata, ProgressIndicator progress) { progress.NewTask(20); Stream audio = formatdata.AddStream(this, AudioName); progress.SetNextWeight(1); List <AudioFormat.Mapping> oldmaps = audioformat.Mappings; ushort[] masks = PlatformRB2WiiCustomDLC.RemixAudioTracks(formatdata.Song, audioformat); progress.SetNextWeight(14); long samples = audioformat.Decoder.Samples; CryptedMoggStream mogg = new CryptedMoggStream(audio); //mogg.WriteHeader(samples); mogg.WriteHeader(); RawkAudio.Encoder encoder = new RawkAudio.Encoder(mogg, audioformat.Channels, audioformat.Decoder.SampleRate, 28000); progress.NewTask("Transcoding Audio", samples); JaggedShortArray buffer = new JaggedShortArray(encoder.Channels, audioformat.Decoder.AudioBuffer.Rank2); AudioFormat.ProcessOffset(audioformat.Decoder, encoder, audioformat.InitialOffset); while (samples > 0) { //int read = audioformat.Decoder.Read((int)Math.Min(samples, 0x4E20)); //int read = audioformat.Decoder.Read((int)Math.Min(samples, 0x20)); int read = audioformat.Decoder.Read((int)Math.Min(samples, buffer.Rank2)); if (read <= 0) { break; } audioformat.Decoder.AudioBuffer.DownmixTo(buffer, masks, read); encoder.Write(buffer, read); samples -= read; progress.Progress(read); //mogg.Update(read); } progress.EndTask(); progress.Progress(14); encoder.Dispose(); mogg.WriteEntries(); formatdata.CloseStream(audio); progress.SetNextWeight(6); Stream preview = formatdata.AddStream(this, PreviewName); mogg = new CryptedMoggStream(preview); mogg.WriteHeader(); PlatformRB2WiiCustomDLC.TranscodePreview(formatdata.Song.PreviewTimes, oldmaps, audioformat.Decoder != null ? audioformat.Decoder : new ZeroDecoder(1, 28000, 0x7FFFFFFFFFFFFFFF), mogg, progress); formatdata.CloseStream(preview); progress.EndTask(); progress.Progress(6); Stream formatstream = formatdata.AddStream(this, FormatName); audioformat.Save(formatstream); formatdata.CloseStream(formatstream); }