private void btnExtract_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtInput.Text) && !string.IsNullOrEmpty(txtOutput.Text)) { var track = LoadTrack(); txtTrackInfo.Text = track.PrintSamplesInfo(); for (int i = 0; i < track.Samples.Count; i++) { string fileOut = Path.GetFileNameWithoutExtension(txtInput.Text) + "_" + (i + 1) + ".wav"; fileOut = Path.Combine(txtOutput.Text, fileOut); File.WriteAllBytes(fileOut, WavUtil.AddWavHeader(track.GetSampleData(track.Samples[i], true, track.Is2018Format), track.Is2018Format ? (byte)32 : (byte)16)); } } }
public byte[] GetSampleData(AudioSample sample, bool decompress, bool scaleTo32bit) { byte[] retval = null; if (!Is2018Format && sample.Compressed && decompress) { retval = adpcm2pcm(sample.Location, sample.Size); } else { retval = new byte[sample.Size]; Array.Copy(_data, sample.Location, retval, 0, sample.Size); } if (scaleTo32bit) { retval = WavUtil.ChangeBitDepth16to32(retval); } return(retval); }