-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnalysisSampleProvider.cs
38 lines (31 loc) · 1.08 KB
/
AnalysisSampleProvider.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using NAudio.Wave;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NHMPh_music_player
{
public class AnalysisSampleProvider : ISampleProvider
{
private readonly ISampleProvider source;
private float[] analysisBuffer;
public WaveFormat WaveFormat => source.WaveFormat;
public AnalysisSampleProvider(ISampleProvider source)
{
this.source = source;
this.analysisBuffer = new float[1024]; // Adjust size as needed
}
public int Read(float[] buffer, int offset, int count)
{
Console.WriteLine("Running");
// Read audio data from the source
int samplesRead = source.Read(buffer, offset, count);
// Copy data to analysis buffer
Array.Copy(buffer, offset, analysisBuffer, 0, samplesRead);
// Here you can analyze the data in analysisBuffer
// For example, perform FFT, signal processing, etc.
return samplesRead;
}
}
}