Exemple #1
0
        public Task WriteFileAsync(PCM16Audio lwav, string output_dir, string original_filename_no_ext)
        {
            var    msf     = MSF.FromAudioSource(lwav, big_endian: big_endian);
            string outPath = Path.Combine(output_dir, original_filename_no_ext + ".msf");

            File.WriteAllBytes(outPath, msf.Export());
            return(Task.CompletedTask);
        }
Exemple #2
0
 public Task <PCM16Audio> ReadFileAsync(string filename)
 {
     byte[] data = File.ReadAllBytes(filename);
     try {
         IPcmAudioSource <short> msf = MSF.Parse(data);
         var lwav = new PCM16Audio(
             msf.Channels,
             msf.SampleRate,
             msf.SampleData.ToArray(),
             msf.LoopStartSample,
             msf.LoopStartSample + msf.LoopSampleCount,
             !msf.IsLooping);
         if (msf is MSF_MP3 mp3)
         {
             lwav.OriginalMP3 = mp3.Body;
         }
         return(Task.FromResult(lwav));
     } catch (NotSupportedException) {
         throw new AudioImporterException("Cannot read MSF file (unsupported codec?)");
     }
 }