- Posts: 2
- Joined: Thu Jul 30, 2020 6:10 am
- Real Name: jeonyuheon
Hello
Sorry for using the translator.
First of all, sorry.
I have no basic knowledge.
I am currently using Decklink Duo 2 and coding using Capture Preview CSharp in Blackmagic DeckLink SDK 11.4.
Play Audio using Waveout Class and BufferedWaveProvider Class.
I want to set 8 channels to EnableAudioInput now
Below is my code.
I set it to 8 channels as above.
And it is a callback function that uses AudioPacket.
There is no problem with 2 channels, but the sound is strange with 8 channels.
Sorry for the very rudimentary question.
please answer about my question.
Sorry for using the translator.
First of all, sorry.
I have no basic knowledge.
I am currently using Decklink Duo 2 and coding using Capture Preview CSharp in Blackmagic DeckLink SDK 11.4.
Play Audio using Waveout Class and BufferedWaveProvider Class.
I want to set 8 channels to EnableAudioInput now
Below is my code.
- Code: Select all
uint channelCount = 8;
m_deckLinkInput.EnableAudioInput(_BMDAudioSampleRate.bmdAudioSampleRate48kHz,
_BMDAudioSampleType.bmdAudioSampleType16bitInteger, channelCount);
_waveFormat.nBlockAlign = (short)((_waveFormat.wBitsPerSample * _waveFormat.nChannels) / 8);
WaveOutInit();
//Waveout initialize
private void WaveOutInit()
{
m_waveProvider = new BufferedWaveProvider(new WaveFormat(48000, 16, 2));
m_waveProvider.DiscardOnBufferOverflow = true;
m_waveOut.Init(m_waveProvider);
m_waveOut.Volume = 0;
}
I set it to 8 channels as above.
And it is a callback function that uses AudioPacket.
- Code: Select all
void IDeckLinkInputCallback.VideoInputFrameArrived(IDeckLinkVideoInputFrame videoFrame, IDeckLinkAudioInputPacket audioPacket)
{
if (videoFrame != null)
{
bool inputSignal = videoFrame.GetFlags().HasFlag(_BMDFrameFlags.bmdFrameHasNoInputSource);
if (inputSignal != m_validInputSignal)
{
m_validInputSignal = inputSignal;
InputSignalChanged(m_validInputSignal);
}
}
System.Runtime.InteropServices.Marshal.ReleaseComObject(videoFrame);
if (audioPacket != null)
{
IntPtr pBuffer;
audioPacket.GetBytes(out pBuffer);
if (IntPtr.Zero != pBuffer)
{
var sampleCount = audioPacket.GetSampleFrameCount();
var bufferLength = sampleCount * _waveFormat.nBlockAlign;
var tempBuffer = new byte[bufferLength];
Marshal.Copy(pBuffer, tempBuffer, 0, bufferLength);
m_waveProvider.AddSamples(tempBuffer, 0, bufferLength);
}
System.Runtime.InteropServices.Marshal.ReleaseComObject(audioPacket);
}
}
There is no problem with 2 channels, but the sound is strange with 8 channels.
Sorry for the very rudimentary question.
please answer about my question.