public void LoadAudio(Stream stream, IFileFormat format) { stream.Position = 0; Format = format; foreach (string ext in Format.Extension) { string extension = ext.TrimStart('*'); switch (extension) { case ".bfstm": case ".bcstm": case ".bfwav": case ".bcwav": var bcfstmReader = new BCFstmReader(); audioWithConfig = bcfstmReader.ReadWithConfig(stream); stream.Position = 0; bxstmStructure = bcfstmReader.ReadMetadata(stream); break; case ".brstm": case ".brwav": var brstmReader = new BrstmReader(); bxstmStructure = brstmReader.ReadMetadata(stream); stream.Position = 0; audioWithConfig = brstmReader.ReadWithConfig(stream); break; case ".idsp": var idspReader = new IdspReader(); idspStructure = idspReader.ReadMetadata(stream); stream.Position = 0; audioWithConfig = idspReader.ReadWithConfig(stream); break; case ".hps": var hpsReader = new HpsReader(); hpsStructure = hpsReader.ReadMetadata(stream); stream.Position = 0; audioWithConfig = hpsReader.ReadWithConfig(stream); break; case ".wav": var wavReader = new WaveReader(); waveStructure = wavReader.ReadMetadata(stream); stream.Position = 0; audioWithConfig = wavReader.ReadWithConfig(stream); break; default: throw new Exception("Unsupported Extension " + ext); } audioData = audioWithConfig.Audio; } }
public Stream unpackWavStream(string file) { for (int i = 0; i < amtaData.Count; i++) { if ((audioIdntr[i] == ".bfwav" || audioIdntr[i] == ".bfstp" || audioIdntr[i] == ".bfstm") && strgList[i].name == file) { Stream f = new MemoryStream(); BCFstmReader reader = new BCFstmReader(); WaveWriter writer = new WaveWriter(); VGAudio.Formats.AudioData convertedWav = reader.Read(audioData[i]); writer.WriteToStream(convertedWav, f); return(f); } } return(null); }
public void unpackWav(string file) { Directory.CreateDirectory(file); for (int i = 0; i < amtaData.Count; i++) { if (audioIdntr[i] == ".bfwav") { FileStream f = File.Create(file + "/" + strgList[i].name + ".wav"); BCFstmReader reader = new BCFstmReader(); WaveWriter writer = new WaveWriter(); VGAudio.Formats.AudioData convertedWav = reader.Read(audioData[i]); writer.WriteToStream(convertedWav, f); f.Close(); } } }
public void BcstmLoopAlignmentIsSet() { GcAdpcmFormat audio = GenerateAudio.GenerateAdpcmSineWave(BuildParseTestOptions.Samples, 1, BuildParseTestOptions.SampleRate); audio = audio.WithLoop(true, 1288, 16288); var writer = new BCFstmWriter(NwTarget.Ctr) { Configuration = { LoopPointAlignment = 700 } }; byte[] builtFile = writer.GetFile(audio); IAudioFormat parsedAudio = new BCFstmReader().ReadFormat(builtFile); Assert.Equal(1400, parsedAudio.LoopStart); Assert.Equal(16400, parsedAudio.LoopEnd); }
public AudioData GetAudioData() { BCFstmReader reader = new BCFstmReader(); return(reader.Read(Data)); }