koznov123
08-19-2016, 06:05 AM
I try send audio frame in c#. But i can't convert byte array to // The audio data, float[] public IntPtr p_data;
For example.
The first I init audio frame.
NDI.NDIlib_audio_frame_t audioFrame = new NDIlib_audio_frame_t()
{
sample_rate= 48000,
no_channels = 2,
no_samples = 1920,
timecode = 0,
p_data = bufferPtrA,
channel_stride_in_bytes = 7680
};
Than I read my wave file from disk.(Format: pcm16 )
byte[] data = File.ReadAllBytes(@"C:\temp\mono.wav");
And convert this to float.
In the end i send this frame.
NDI.Send.NDIlib_send_send_audio(sendInstancePtr, ref audioFrame);
I try get pcm data and doesn't changes.
Double[] data;
byte[] wave;
byte[] sR = new byte[4];
System.IO.FileStream WaveFile = System.IO.File.OpenRead(wavePath);
wave = new byte[WaveFile.Length];
data = new Double[(wave.Length - 44) / 4];//shifting the headers out of the PCM data;
WaveFile.Read(wave, 0, Convert.ToInt32(WaveFile.Length));//read the wave file into the wave variable
/***********Converting and PCM accounting***************/
for (int i = 0; i < data.Length; i += 2)
{
data[i] = BitConverter.ToInt16(wave, i) / 32768.0;
}
/**************assigning sample rate**********************/
for (int i = 24; i < 28; i++)
{
sR[i - 24] = wave[i];
}
SampleRate = BitConverter.ToInt16(sR, 0);
return data;
Please help. how can I convert bytes array to p_data(float)?
For example.
The first I init audio frame.
NDI.NDIlib_audio_frame_t audioFrame = new NDIlib_audio_frame_t()
{
sample_rate= 48000,
no_channels = 2,
no_samples = 1920,
timecode = 0,
p_data = bufferPtrA,
channel_stride_in_bytes = 7680
};
Than I read my wave file from disk.(Format: pcm16 )
byte[] data = File.ReadAllBytes(@"C:\temp\mono.wav");
And convert this to float.
In the end i send this frame.
NDI.Send.NDIlib_send_send_audio(sendInstancePtr, ref audioFrame);
I try get pcm data and doesn't changes.
Double[] data;
byte[] wave;
byte[] sR = new byte[4];
System.IO.FileStream WaveFile = System.IO.File.OpenRead(wavePath);
wave = new byte[WaveFile.Length];
data = new Double[(wave.Length - 44) / 4];//shifting the headers out of the PCM data;
WaveFile.Read(wave, 0, Convert.ToInt32(WaveFile.Length));//read the wave file into the wave variable
/***********Converting and PCM accounting***************/
for (int i = 0; i < data.Length; i += 2)
{
data[i] = BitConverter.ToInt16(wave, i) / 32768.0;
}
/**************assigning sample rate**********************/
for (int i = 24; i < 28; i++)
{
sR[i - 24] = wave[i];
}
SampleRate = BitConverter.ToInt16(sR, 0);
return data;
Please help. how can I convert bytes array to p_data(float)?