【发布时间】:2014-05-12 11:44:15
【问题描述】:
我正在使用 C# 包装器 ohLibSpotify 从 Spotify 流式传输音乐,并使用 NAudio 播放它。现在我正在尝试为我收到的数据创建频谱可视化。
当我从 libspotify 获取数据时,会调用以下回调:
public void MusicDeliveryCallback(SpotifySession session, AudioFormat format, IntPtr frames, int num_frames)
{
//handle received music data from spotify for streaming
//format: audio format for streaming
//frames: pointer to the byte-data in storage
var size = num_frames * format.channels * 2;
if (size != 0)
{
_copiedFrames = new byte[size];
Marshal.Copy(frames, _copiedFrames, 0, size); //Copy Pointer Bytes to _copiedFrames
_bufferedWaveProvider.AddSamples(_copiedFrames, 0, size); //adding bytes from _copiedFrames as samples
}
}
是否可以分析我传递给 BufferedWaveProvider 的数据以创建实时可视化?有人可以解释一下吗?
【问题讨论】:
标签: c# visualization naudio libspotify