C#言語と.NET Frameworkを使用したサウンドビジュアライゼーションシステムを作成したいと考えています。 これはWinampアプリケーションのように見えます。 おそらく、無料のライブラリやそれを行う方法を説明する興味深い記事がありますか? 例: alt text http://img44.imageshack.us/img44/9982/examplel.pngC#サウンドビジュアライゼーション
答えて
あなたは(C#で書かれた音楽の可視化を、開発するための無料のオープンソース・プラットフォームである)これらのリンク
OpenVPを試すことができ、OpenVP Screenshotsを参照してください。
Play and Visualize WAV Files using Managed Direct Sound
さようなら。
ここには、WASAPI APIを使用してコンピュータ上で再生されるサウンドのFFTを計算するスクリプトがあります。これは別のスレッドで修正されているので、まずそれをロックすることをお勧めします別のスクリプトからbarDataを取得する際に続いて
using CSCore;
using CSCore.SoundIn;
using CSCore.Codecs.WAV;
using WinformsVisualization.Visualization;
using CSCore.DSP;
using CSCore.Streams;
using System;
public class SoundCapture
{
public int numBars = 30;
public int minFreq = 5;
public int maxFreq = 4500;
public int barSpacing = 0;
public bool logScale = true;
public bool isAverage = false;
public float highScaleAverage = 2.0f;
public float highScaleNotAverage = 3.0f;
LineSpectrum lineSpectrum;
WasapiCapture capture;
WaveWriter writer;
FftSize fftSize;
float[] fftBuffer;
SingleBlockNotificationStream notificationSource;
BasicSpectrumProvider spectrumProvider;
IWaveSource finalSource;
public SoundCapture()
{
// This uses the wasapi api to get any sound data played by the computer
capture = new WasapiLoopbackCapture();
capture.Initialize();
// Get our capture as a source
IWaveSource source = new SoundInSource(capture);
// From https://github.com/filoe/cscore/blob/master/Samples/WinformsVisualization/Form1.cs
// This is the typical size, you can change this for higher detail as needed
fftSize = FftSize.Fft4096;
// Actual fft data
fftBuffer = new float[(int)fftSize];
// These are the actual classes that give you spectrum data
// The specific vars of lineSpectrum here aren't that important because they can be changed by the user
spectrumProvider = new BasicSpectrumProvider(capture.WaveFormat.Channels,
capture.WaveFormat.SampleRate, fftSize);
lineSpectrum = new LineSpectrum(fftSize)
{
SpectrumProvider = spectrumProvider,
UseAverage = true,
BarCount = numBars,
BarSpacing = 2,
IsXLogScale = false,
ScalingStrategy = ScalingStrategy.Linear
};
// Tells us when data is available to send to our spectrum
var notificationSource = new SingleBlockNotificationStream(source.ToSampleSource());
notificationSource.SingleBlockRead += NotificationSource_SingleBlockRead;
// We use this to request data so it actualy flows through (figuring this out took forever...)
finalSource = notificationSource.ToWaveSource();
capture.DataAvailable += Capture_DataAvailable;
capture.Start();
}
private void Capture_DataAvailable(object sender, DataAvailableEventArgs e)
{
finalSource.Read(e.Data, e.Offset, e.ByteCount);
}
private void NotificationSource_SingleBlockRead(object sender, SingleBlockReadEventArgs e)
{
spectrumProvider.Add(e.Left, e.Right);
}
~SoundCapture()
{
capture.Stop();
capture.Dispose();
}
public float[] barData = new float[20];
public float[] GetFFtData()
{
lock (barData)
{
lineSpectrum.BarCount = numBars;
if (numBars != barData.Length)
{
barData = new float[numBars];
}
}
if (spectrumProvider.IsNewDataAvailable)
{
lineSpectrum.MinimumFrequency = minFreq;
lineSpectrum.MaximumFrequency = maxFreq;
lineSpectrum.IsXLogScale = logScale;
lineSpectrum.BarSpacing = barSpacing;
lineSpectrum.SpectrumProvider.GetFftData(fftBuffer, this);
return lineSpectrum.GetSpectrumPoints(100.0f, fftBuffer);
}
else
{
return null;
}
}
public void ComputeData()
{
float[] resData = GetFFtData();
int numBars = barData.Length;
if (resData == null)
{
return;
}
lock (barData)
{
for (int i = 0; i < numBars && i < resData.Length; i++)
{
// Make the data between 0.0 and 1.0
barData[i] = resData[i]/100.0f;
}
for (int i = 0; i < numBars && i < resData.Length; i++)
{
if (lineSpectrum.UseAverage)
{
// Scale the data because for some reason bass is always loud and treble is soft
barData[i] = barData[i] + highScaleAverage * (float)Math.Sqrt(i/(numBars + 0.0f)) * barData[i];
}
else
{
barData[i] = barData[i] + highScaleNotAverage * (float)Math.Sqrt(i/(numBars + 0.0f)) * barData[i];
}
}
}
}
}
:それはCSCoreとそのWinformsVisualization例を使用しています。
Github Repoのように見えないので、私はGetSpectrumPoints
がどこにあるのか分かりませんが、ここにあります。そのファイルに貼り付けてください。私のコードはうまくいくはずです。
public float[] GetSpectrumPoints(float height, float[] fftBuffer)
{
SpectrumPointData[] dats = CalculateSpectrumPoints(height, fftBuffer);
float[] res = new float[dats.Length];
for (int i = 0; i < dats.Length; i++)
{
res[i] = (float)dats[i].Value;
}
return res;
}
私はあなたのサンプルコードを使用しようとしましたが、['GetSpectrumPoints()'はもう関数ではありません](https://github.com/filoe/cscore/blob/29410b12ae35321c4556b072c0711a8f289c0544/Samples/ WinformsVisualization/Visualization/LineSpectrum.cs#L10)、gitリポジトリの履歴を確認しても表示されません。答えを明確にしたり更新したりしてもよろしいですか? (*私はWindows上でオーディオキャプチャ/処理を、LED照明を駆動するクロスプラットフォームコンソールアプリケーションと統合しようとしています; 0.0〜1.0の周波数データ値がすべて必要です)* – Shane
@Shane申し訳ありません!私は今、そのコードを追加しました。 – Phylliida
- 1. C/C++/Java/C#
- 2. iPhone用C対C++(Objective-C対Objective-C++)
- 3. C、C#、C++、Java用のC#コードアナライザ。
- 4. matlab in C C++とC C++ in matlab
- 5. C/C++
- 6. c、C++、c#の機能テストツール
- 7. WindowsスタートアップアプリケーションC/C++
- 8. C/C++ビジュアルライブラリ
- 9. C/C++ Windowsトラフィックブロッカー
- 10. コンパイルC++ C#の
- 11. C/C++ JSONパーサー
- 12. C/C++ FLACタグライブラリ
- 13. C〜C++コンバータ
- 14. C/C++マルチマップライブラリ
- 15. C/C++コード
- 16. C# - C++ Intellisense textbox
- 17. C++ロジック、c#gui
- 18. Cラッパーfor C++
- 19. C#/ C++ pInvoke tips
- 20. c/C++のReSharper
- 21. emacs c C++リファレンスドキュメント
- 22. C to C++ printf
- 23. C/C++ ncurses freeze
- 24. C/C++ USBドライブイベント
- 25. C++からC#
- 26. C/C++プリプロセスエラー
- 27. C/C++のワークフローエンジン
- 28. Xcode&C/C++プロジェクト
- 29. TFS API C#:C#
- 30. C/C++ Static Voodoo
私はそれが始まり、おかげで良いと思う。 –