【问题标题】:How to speed up/delay an audio file in c#?如何在 C# 中加速/延迟音频文件?
【发布时间】:2022-12-07 19:12:58
【问题描述】:

如何提高或降低音频文件的播放速度(音调应该改变)。我应该使用什么方法和库?现在我正在尝试NAudio,但据我所知,这个库没有我需要的功能。我也试过soundtouch,但我不明白它是如何工作的。

【问题讨论】:

    标签: c# .net .net-core


    【解决方案1】:

    也许这样的事情适用于soundtouch

    // Open the audio file
    var reader = new AudioFileReader("AudioFile.mp3");
    
    // Create a new SoundTouch instance
    var soundTouch = new SoundTouch();
    
    // Set the playback speed
    soundTouch.Rate = 1.5; // Play at 1.5x speed
    
    // Set the input of the SoundTouch instance to the audio file reader
    soundTouch.SetInput(reader);
    
    // Create a new wave out to play the audio
    var waveOut = new WaveOut();
    
    // Use the SoundTouch instance as the wave out's source
    waveOut.Init(soundTouch);
    
    // Play the audio
    waveOut.Play();
    

    或者这个NAudio

    // Open the audio file
    var reader = new AudioFileReader("AudioFile.mp3");
    
    // Change the playback speed
    reader.PlaybackRate = 1.5; // Play at 1.5x speed
    
    // Create a new wave out to play the audio
    var waveOut = new WaveOut();
    
    // Use the audio file reader as the wave out's source
    waveOut.Init(reader);
    
    // Play the audio
    waveOut.Play();
    

    【讨论】:

    • 非常感谢你的回复!但我有一个问题。使用 NAudio 我不能使用reader.PlaybackRate。 “AudioFileReader”没有“PlaybackRate”的定义。我错过了一些using吗?
    猜你喜欢
    • 1970-01-01
    • 2013-01-03
    • 1970-01-01
    • 2013-12-15
    • 2014-11-10
    • 2015-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多