コード例 #1
0
        public void Dispose()
        {
            if (!_isDisposed && (Data != IntPtr.Zero))
            {
                switch (Format)
                {
                case AudioFormat.Wav: NativeAudio.FreeWav(Data); break;

                case AudioFormat.Ogg: NativeAudio.Free(Data); break;

                case AudioFormat.Flac: NativeAudio.FreeFlac(Data); break;

                case AudioFormat.Mp3: NativeAudio.FreeMp3(Data); break;
                }
            }
            _isDisposed = true;
        }
コード例 #2
0
ファイル: AudioImporter.cs プロジェクト: SpectrumLib/Spectrum
        public override RawAudio Import(FileStream stream, ImporterContext ctx)
        {
            // Select loader based on the extension
            RawAudio ra = null;

            switch (ctx.FileExtension)
            {
            case ".wav": ra = NativeAudio.LoadWave(ctx.FilePath); break;

            case ".flac": ra = NativeAudio.LoadFlac(ctx.FilePath); break;

            case ".ogg": ra = NativeAudio.LoadVorbis(ctx.FilePath); break;

            case ".mp3": ra = NativeAudio.LoadMp3(ctx.FilePath); break;

            default:
                ctx.Logger.Error($"unsupported audio file format '{ctx.FileExtension.Substring(1)}'.");
                return(null);
            }

            // Good to move forward
            return(ra);
        }