【发布时间】:2014-05-03 06:58:21
【问题描述】:
如何使用 NAudio 将流(以 byte[] 采样并编码为 PCM)保存到 mp3 文件?我已经听说过新的 Nadio Lame 编码器,但并不真正了解它。
我已经在网上搜索过,但并没有真正找到有用的东西。
我现在可以播放的内容:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NAudio;
namespace PLAYER
{
class NAudioPlayer : Player
{
NAudio.Wave.BufferedWaveProvider buf;
NAudio.Wave.IWavePlayer player;
int times = 0;
public int EnqueueSamples(int channels, int rate, byte[] samples, int frames)
{
if (buf == null)
{
buf = new NAudio.Wave.BufferedWaveProvider(new NAudio.Wave.WaveFormat(rate, channels));
NAudio.Wave.WaveOut dso = new NAudio.Wave.WaveOut();
dso.Init(buffer);
dso.Play();
player = dso;
}
int space = buf.BufferLength - buf.BufferedBytes;
if (space > samples.Length)
{
if (times == 0)
times = (times + 1) % 100;
buf.AddSamples(samples, 0, samples.Length);
return frames;
}
return 0;
}
public void Reset()
{
if (buffer != null) buffer.ClearBuffer();
}
}
你能帮我提供一个代码sn-p吗? 或者只是告诉我在哪里可以找到有用的 sn-p?
【问题讨论】:
标签: c# mp3 bytearray naudio pcm