AJA NTV2 SDK  18.0.0.2122
NTV2 SDK 18.0.0.2122
ntv2audio.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
7 #include "ntv2card.h"
8 #include "ntv2devicefeatures.h"
9 #include "ntv2utils.h"
10 #include "ntv2audiodefines.h"
11 #include "ajabase/common/common.h"
12 #include "ajabase/system/debug.h"
13 #ifdef MSWindows
14  #include <math.h>
15  #pragma warning(disable: 4800)
16 #endif // MSWindows
17 
18 using namespace std;
19 
20 
21 #define AUDFAIL(__x__) AJA_sERROR (AJA_DebugUnit_AudioGeneric, " " << HEX0N(uint64_t(this),16) << "::" << AJAFUNC << ": " << __x__)
22 #define AUDWARN(__x__) AJA_sWARNING(AJA_DebugUnit_AudioGeneric, " " << HEX0N(uint64_t(this),16) << "::" << AJAFUNC << ": " << __x__)
23 #define AUDNOTE(__x__) AJA_sNOTICE (AJA_DebugUnit_AudioGeneric, " " << HEX0N(uint64_t(this),16) << "::" << AJAFUNC << ": " << __x__)
24 #define AUDINFO(__x__) AJA_sINFO (AJA_DebugUnit_AudioGeneric, " " << HEX0N(uint64_t(this),16) << "::" << AJAFUNC << ": " << __x__)
25 #define AUDDBUG(__x__) AJA_sDEBUG (AJA_DebugUnit_AudioGeneric, " " << HEX0N(uint64_t(this),16) << "::" << AJAFUNC << ": " << __x__)
26 
27 
30 
33 
36 
39 
42 
44 
47 
50 
53 
58  inline PCM_CONTROL_INFO(ULWord regNum, ULWord mask, ULWord shift) : pcmControlReg(regNum), pcmControlMask(mask), pcmControlShift(shift){}
59 };
60 
62 {
63  {
72  },
73  {
82  },
83  {
92  },
93  {
102  },
103  {
112  },
113  {
122  },
123  {
132  },
133  {
142  }
143 };
144 
145 
146 bool CNTV2Card::SetNumberAudioChannels (const ULWord inNumChannels, const NTV2AudioSystem inAudioSystem)
147 {
148  const ULWord regAudControl (NTV2_IS_VALID_AUDIO_SYSTEM (inAudioSystem) ? gAudioSystemToAudioControlRegNum [inAudioSystem] : 0);
149 
150  if (regAudControl == 0)
151  return false;
152  else if (inNumChannels == 6 || inNumChannels == 8)
153  {
154  // Make sure 16 channel audio is off
155  WriteRegister (regAudControl, 0, kRegMaskAudio16Channel, kRegShiftAudio16Channel);
156 
157  // Now turn on 6 or 8 channel audio
158  return WriteRegister (regAudControl, inNumChannels == 8, kRegMaskNumChannels, kRegShiftNumChannels);
159  }
160  else if (inNumChannels == 16)
161  {
162  // Turn 16 channel audio on, doesn't matter how 8 or 6 channel is set
163  return WriteRegister (regAudControl, 1, kRegMaskAudio16Channel, kRegShiftAudio16Channel);
164  }
165  else
166  return false;
167 }
168 
169 
170 bool CNTV2Card::SetNumberAudioChannels (const ULWord inNumChannels, const NTV2AudioSystemSet & inAudioSystems)
171 {
172  size_t numFailures(0);
173  for (NTV2AudioSystemSetConstIter it(inAudioSystems.begin()); it != inAudioSystems.end(); ++it)
174  if (!SetNumberAudioChannels (inNumChannels, *it))
175  numFailures++;
176  return numFailures == 0;
177 }
178 
179 
180 bool CNTV2Card::GetNumberAudioChannels (ULWord & outNumChannels, const NTV2AudioSystem inAudioSystem)
181 {
182  const ULWord regAudControl (NTV2_IS_VALID_AUDIO_SYSTEM (inAudioSystem) ? gAudioSystemToAudioControlRegNum [inAudioSystem] : 0);
183  ULWord value (0);
184  bool status (false);
185 
186  if (regAudControl == 0)
187  return false;
188 
189  status = ReadRegister (regAudControl, value, kRegMaskAudio16Channel, kRegShiftAudio16Channel);
190  if (value == 1)
191  outNumChannels = 16;
192  else
193  {
194  status = ReadRegister (regAudControl, value, kRegMaskNumChannels, kRegShiftNumChannels);
195  if (value == 1)
196  outNumChannels = 8;
197  else
198  outNumChannels = 6;
199  }
200 
201  return status;
202 }
203 
204 
205 bool CNTV2Card::SetAudioRate (const NTV2AudioRate inRate, const NTV2AudioSystem inAudioSystem)
206 {
207  ULWord rateLow (0);
208  ULWord rateHigh (0);
209  bool status;
210 
211  if ((inRate == NTV2_AUDIO_192K) && (inAudioSystem == NTV2_AUDIOSYSTEM_1))
212  return false;
213 
214  if (inRate == NTV2_AUDIO_96K)
215  rateLow = 1;
216  else if (inRate == NTV2_AUDIO_192K)
217  rateHigh = 1;
218 
219  status = WriteRegister (gAudioSystemToAudioControlRegNum [inAudioSystem], rateLow, kRegMaskAudioRate, kRegShiftAudioRate);
220  status &= WriteRegister (kRegAudioControl2, rateHigh, gAudioRateHighMask [inAudioSystem], gAudioRateHighShift [inAudioSystem]);
221 
222  return status;
223 }
224 
225 
226 bool CNTV2Card::GetAudioRate (NTV2AudioRate & outRate, const NTV2AudioSystem inAudioSystem)
227 {
228  ULWord rateLow (0);
229  ULWord rateHigh (0);
230  bool status;
231 
232  status = ReadRegister (gAudioSystemToAudioControlRegNum [inAudioSystem], rateLow, kRegMaskAudioRate, kRegShiftAudioRate);
233  status &= ReadRegister (kRegAudioControl2, rateHigh, gAudioRateHighMask [inAudioSystem], gAudioRateHighShift [inAudioSystem]);
234  if (status)
235  {
236  if ((rateLow == 0) && (rateHigh == 0))
237  outRate = NTV2_AUDIO_48K;
238  else if ((rateLow == 1) && (rateHigh == 0))
239  outRate = NTV2_AUDIO_96K;
240  else if ((rateLow == 0) && (rateHigh == 1))
241  outRate = NTV2_AUDIO_192K;
242  else
243  status = false;
244  }
245  return status;
246 }
247 
248 
249 bool CNTV2Card::SetAudioBufferSize (const NTV2AudioBufferSize inValue, const NTV2AudioSystem inAudioSystem)
250 {
251  if (!NTV2_IS_VALID_AUDIO_SYSTEM(inAudioSystem))
252  return false;
253  if (inValue != NTV2_AUDIO_BUFFER_SIZE_4MB && IsSupported(kDeviceCanDoStackedAudio))
254  return false; // Stacked audio devices are fixed at 4MB
255  return WriteRegister (gAudioSystemToAudioControlRegNum[inAudioSystem], inValue, kK2RegMaskAudioBufferSize, kK2RegShiftAudioBufferSize);
256 }
257 
258 bool CNTV2Card::SetAudioBufferSize (const NTV2AudioBufferSize inMode, const NTV2AudioSystemSet & inAudioSystems)
259 {
260  size_t numFailures(0);
261  for (NTV2AudioSystemSetConstIter it(inAudioSystems.begin()); it != inAudioSystems.end(); ++it)
262  if (!SetAudioBufferSize (inMode, *it))
263  numFailures++;
264  return numFailures == 0;
265 }
266 
267 
269 {
270  if (!NTV2_IS_VALID_AUDIO_SYSTEM(inAudioSystem))
271  return false;
272  outSize = NTV2_AUDIO_BUFFER_SIZE_4MB; // NTV2 has standardized on 4MB audio buffers
273  if (IsSupported(kDeviceCanDoStackedAudio))
274  return true; // Done!
275 
277 }
278 
279 
280 bool CNTV2Card::SetAudioAnalogLevel (const NTV2AudioLevel inLevel, const NTV2AudioSystem inAudioSystem)
281 {
282  (void)inAudioSystem;
283  if (IsSupported(kDeviceHasBreakoutBoard))
285  else
286  return WriteRegister (kRegAud1Control, inLevel, kFS1RegMaskAudioLevel, kFS1RegShiftAudioLevel);
287 }
288 
289 
290 bool CNTV2Card::GetAudioAnalogLevel (NTV2AudioLevel & outLevel, const NTV2AudioSystem inAudioSystem)
291 {
292  (void)inAudioSystem;
293  if (IsSupported(kDeviceHasBreakoutBoard))
295  else
297 }
298 
299 
300 bool CNTV2Card::SetAudioLoopBack (const NTV2AudioLoopBack inValue, const NTV2AudioSystem inAudioSystem)
301 {
302  if (!NTV2_IS_VALID_AUDIO_LOOPBACK(inValue))
303  return false;
304  if (!NTV2_IS_VALID_AUDIO_SYSTEM(inAudioSystem))
305  return false;
306  if (inValue == NTV2_AUDIO_LOOPBACK_ON)
307  SetEmbeddedAudioClock (NTV2_EMBEDDED_AUDIO_CLOCK_REFERENCE, inAudioSystem); // Use board reference as audio clock
308  return WriteRegister (gAudioSystemToAudioControlRegNum [inAudioSystem], inValue, kRegMaskLoopBack, kRegShiftLoopBack);
309 }
310 
311 bool CNTV2Card::SetAudioLoopBack (const NTV2AudioLoopBack inMode, const NTV2AudioSystemSet & inAudioSystems)
312 {
313  size_t numFailures(0);
314  for (NTV2AudioSystemSetConstIter it(inAudioSystems.begin()); it != inAudioSystems.end(); ++it)
315  if (!SetAudioLoopBack (inMode, *it))
316  numFailures++;
317  return numFailures == 0;
318 }
319 
320 
321 bool CNTV2Card::GetAudioLoopBack (NTV2AudioLoopBack & outValue, const NTV2AudioSystem inAudioSystem)
322 {
323  outValue = NTV2_AUDIO_LOOPBACK_INVALID;
324  if (!NTV2_IS_VALID_AUDIO_SYSTEM(inAudioSystem))
325  return false;
327 }
328 
329 
331 {
332  if (!NTV2_IS_VALID_AUDIO_SYSTEM(inAudioSystem))
333  return false;
334  return WriteRegister (gAudioSystemToAudioControlRegNum[inAudioSystem], inMode, kRegMaskEncodedAudioMode, kRegShiftEncodedAudioMode);
335 }
336 
337 
339 {
340  if (!NTV2_IS_VALID_AUDIO_SYSTEM(inAudioSystem))
341  return false;
343 }
344 
345 
346 bool CNTV2Card::SetEmbeddedAudioInput (const NTV2EmbeddedAudioInput inAudioInput, const NTV2AudioSystem inAudioSystem)
347 {
348  if (!NTV2_IS_VALID_AUDIO_SYSTEM(inAudioSystem))
349  return false;
350  const ULWord regAudSource (gAudioSystemToSrcSelectRegNum [inAudioSystem]);
351  const ULWord numInputs (GetNumSupported(kDeviceGetNumVideoInputs));
352  const ULWord numHDMI (GetNumSupported(kDeviceGetNumHDMIVideoInputs));
353  bool status (false);
354  ULWord value1 (0);
355  ULWord value2 (0);
356 
357  switch (inAudioInput)
358  { // Sparse bits
359  case NTV2_EMBEDDED_AUDIO_INPUT_VIDEO_1: value1 = 0x0; value2 = 0x0; break;
360  case NTV2_EMBEDDED_AUDIO_INPUT_VIDEO_2: value1 = 0x1; value2 = 0x0; break;
361  case NTV2_EMBEDDED_AUDIO_INPUT_VIDEO_3: value1 = 0x0; value2 = 0x1; break;
362  case NTV2_EMBEDDED_AUDIO_INPUT_VIDEO_4: value1 = 0x1; value2 = 0x1; break;
363  case NTV2_EMBEDDED_AUDIO_INPUT_VIDEO_5: value1 = 0x0; value2 = 0x0; break;
364  case NTV2_EMBEDDED_AUDIO_INPUT_VIDEO_6: value1 = 0x1; value2 = 0x0; break;
365  case NTV2_EMBEDDED_AUDIO_INPUT_VIDEO_7: value1 = 0x0; value2 = 0x1; break;
366  case NTV2_EMBEDDED_AUDIO_INPUT_VIDEO_8: value1 = 0x1; value2 = 0x1; break;
367  default: return false;
368  }
369 
370  status = WriteRegister (regAudSource, value1, kRegMaskEmbeddedAudioInput, kRegShiftEmbeddedAudioInput);
371  if (numInputs > 2 || inAudioInput > NTV2_EMBEDDED_AUDIO_INPUT_VIDEO_4 || numHDMI > 1)
372  status = WriteRegister (regAudSource, value2, kRegMaskEmbeddedAudioInput2, kRegShiftEmbeddedAudioInput2);
373  return status;
374 }
375 
376 
378 {
379  if (!NTV2_IS_VALID_AUDIO_SYSTEM(inAudioSystem))
380  return false;
381  const ULWord srcSelectReg (gAudioSystemToSrcSelectRegNum [inAudioSystem]);
382  const ULWord numInputs (GetNumSupported(kDeviceGetNumVideoInputs));
383  ULWord value (0);
384  bool status (false);
385 
386  if (numInputs <= 2)
387  status = ReadRegister (srcSelectReg, value, kRegMaskEmbeddedAudioInput, kRegShiftEmbeddedAudioInput);
388  else
389  {
390  ULWord sparse1(0), sparse2(0); // Sparse bits
391  status = ReadRegister (srcSelectReg, sparse1, kRegMaskEmbeddedAudioInput, kRegShiftEmbeddedAudioInput)
392  && ReadRegister (srcSelectReg, sparse2, kRegMaskEmbeddedAudioInput2, kRegShiftEmbeddedAudioInput2);
393  if (!sparse1 && !sparse2)
395  else if (sparse1 && !sparse2)
397  else if (!sparse1 && sparse2)
399  else if (sparse1 && sparse2)
401 
402  if (inAudioSystem >= NTV2_AUDIOSYSTEM_5)
403  switch (value)
404  {
409  }
410  }
411  if (status)
412  outAudioInput = NTV2EmbeddedAudioInput(value);
413  return status;
414 }
415 
416 
418 {
419  if (!NTV2_IS_VALID_AUDIO_SYSTEM(inAudioSystem))
420  return false;
421  return WriteRegister (gAudioSystemToSrcSelectRegNum[inAudioSystem], inValue, kRegMaskEmbeddedAudioClock, kRegShiftEmbeddedAudioClock);
422 }
423 
424 
426 {
427  if (!NTV2_IS_VALID_AUDIO_SYSTEM(inAudioSystem))
428  return false;
430 }
431 
432 
433 bool CNTV2Card::GetAudioWrapAddress (ULWord & outWrapAddress, const NTV2AudioSystem inAudioSystem)
434 {
436  if (!GetAudioBufferSize (bufferSize, inAudioSystem))
437  return false;
438 
439  switch (bufferSize)
440  {
441  case NTV2_AUDIO_BUFFER_SIZE_1MB: outWrapAddress = NTV2_AUDIO_WRAPADDRESS; break; // (0x000FF000 * 1)
442  case NTV2_AUDIO_BUFFER_SIZE_4MB: outWrapAddress = NTV2_AUDIO_WRAPADDRESS_BIG; break; // (0x000FF000 * 4)
443  default: outWrapAddress = NTV2_AUDIO_WRAPADDRESS; break;
444  }
445  return true;
446 }
447 
448 
449 bool CNTV2Card::GetAudioReadOffset (ULWord & outReadOffset, const NTV2AudioSystem inAudioSystem)
450 {
452  if (!GetAudioBufferSize (bufferSize, inAudioSystem))
453  return false;
454 
455  switch (bufferSize)
456  {
457  case NTV2_AUDIO_BUFFER_SIZE_1MB: outReadOffset = NTV2_AUDIO_READBUFFEROFFSET; break; // (0x00100000 * 1) 1MB
458  case NTV2_AUDIO_BUFFER_SIZE_4MB: outReadOffset = NTV2_AUDIO_READBUFFEROFFSET_BIG; break; // (0x00100000 * 4) 4MB
459  default: outReadOffset = NTV2_AUDIO_READBUFFEROFFSET; break; // (0x00100000 * 1) 1MB
460  }
461  return true;
462 }
463 
464 
465 bool CNTV2Card::ReadAudioLastIn (ULWord & outValue, const NTV2AudioSystem inAudioSystem)
466 {
467  if (!NTV2_IS_VALID_AUDIO_SYSTEM(inAudioSystem))
468  return false;
469  return ReadRegister (gChannelToAudioInLastAddrRegNum[inAudioSystem], outValue);
470 }
471 
472 bool CNTV2Card::ReadAudioLastOut (ULWord & outValue, const NTV2AudioSystem inAudioSystem)
473 {
474  if (!NTV2_IS_VALID_AUDIO_SYSTEM(inAudioSystem))
475  return false;
476  return ReadRegister (gChannelToAudioOutLastAddrRegNum[inAudioSystem], outValue);
477 }
478 
479 #if !defined(NTV2_DEPRECATE_16_0)
480  bool CNTV2Card::ReadAudioSource (ULWord & outValue, const NTV2Channel inChannel) {return ReadRegister(gAudioSystemToSrcSelectRegNum[inChannel], outValue);}
481  bool CNTV2Card::WriteAudioSource (const ULWord inValue, const NTV2Channel inChannel) {return WriteRegister(gAudioSystemToSrcSelectRegNum[inChannel], inValue);}
482 #endif // !defined(NTV2_DEPRECATE_16_0)
483 
484 
485 bool CNTV2Card::SetAudioSystemInputSource (const NTV2AudioSystem inAudioSystem, const NTV2AudioSource inAudioSource, const NTV2EmbeddedAudioInput inEmbeddedSource)
486 {
487  if (!NTV2_IS_VALID_AUDIO_SYSTEM(inAudioSystem))
488  return false;
489  bool result(false);
490  static const ULWord sAudioSourceToRegValues [] = { 0x1, // NTV2_AUDIO_EMBEDDED
491  0x0, // NTV2_AUDIO_AES
492  0x9, // NTV2_AUDIO_ANALOG
493  0xA, // NTV2_AUDIO_HDMI
494  0xB}; // NTV2_AUDIO_MIC
495 
496  if (ULWord(inAudioSystem) < GetNumSupported(kDeviceGetTotalNumAudioSystems))
497  if (NTV2_IS_VALID_AUDIO_SOURCE(inAudioSource))
498  result = WriteRegister (gAudioSystemToSrcSelectRegNum [inAudioSystem],
499  sAudioSourceToRegValues [inAudioSource],
501  if (result)
502  {
503  if ((inAudioSource == NTV2_AUDIO_EMBEDDED) || (inAudioSource == NTV2_AUDIO_HDMI))
504  if (SetEmbeddedAudioInput (inEmbeddedSource, inAudioSystem)) // Use the specified input for grabbing embedded audio
505  result = SetEmbeddedAudioClock (NTV2_EMBEDDED_AUDIO_CLOCK_VIDEO_INPUT, inAudioSystem); // Use video input clock (not reference)
506 
507  if (IsSupported(kDeviceCanDoBreakoutBoard))
508  result = EnableBOBAnalogAudioIn(IsSupported(kDeviceHasBreakoutBoard) && inAudioSource == NTV2_AUDIO_ANALOG);
509  }
510  return result;
511 
512 } // SetAudioSystemInputSource
513 
514 
515 bool CNTV2Card::GetAudioSystemInputSource (const NTV2AudioSystem inAudioSystem, NTV2AudioSource & outAudioSource, NTV2EmbeddedAudioInput & outEmbeddedSource)
516 {
517  if (!NTV2_IS_VALID_AUDIO_SYSTEM(inAudioSystem))
518  return false;
519  ULWord regValue (0);
520 
521  outAudioSource = NTV2_AUDIO_SOURCE_INVALID;
522  outEmbeddedSource = NTV2_EMBEDDED_AUDIO_INPUT_INVALID;
523 
524  if (ULWord(inAudioSystem) >= GetNumSupported(kDeviceGetTotalNumAudioSystems))
525  return false; // Invalid audio system
526  if (!ReadRegister (gAudioSystemToSrcSelectRegNum [inAudioSystem], regValue, kRegMaskAudioSource, kRegShiftAudioSource))
527  return false;
528  switch (regValue & 0x0000000F)
529  {
530  case 0x1: outAudioSource = NTV2_AUDIO_EMBEDDED; break;
531  case 0x0: outAudioSource = NTV2_AUDIO_AES; break;
532  case 0x9: outAudioSource = NTV2_AUDIO_ANALOG; break;
533  case 0xA: outAudioSource = NTV2_AUDIO_HDMI; break;
534  case 0xB: outAudioSource = NTV2_AUDIO_MIC; break;
535  default: return false;
536  }
537 
538  if (outAudioSource == NTV2_AUDIO_EMBEDDED)
539  GetEmbeddedAudioInput(outEmbeddedSource, inAudioSystem);
540  return true;
541 
542 }
543 
544 
547 
548 
550 {
551  outAudioSystem = NTV2_AUDIOSYSTEM_INVALID;
552  if (!IsSupported(kDeviceCanDoAudioMixer))
553  return false; // No Audio Mixer -- shouldn't be calling this function
554  if (!NTV2_IS_VALID_AUDIO_MIXER_INPUT(inMixerInput))
555  return false; // Bad Mixer Input specified
557  sAudioMixerInputSelectMasks[inMixerInput],
558  sAudioMixerInputSelectShifts[inMixerInput]);
559 }
560 
562 {
563  if (!IsSupported(kDeviceCanDoAudioMixer))
564  return false; // No Audio Mixer -- shouldn't be calling this function
565  if (!NTV2_IS_VALID_AUDIO_MIXER_INPUT(inMixerInput))
566  return false; // Bad Mixer Input specified
567  if (ULWord(inAudioSystem) >= GetNumSupported(kDeviceGetNumAudioSystems) + 1)
568  return false; // No such audio system on this device
569  return WriteRegister (kRegAudioMixerInputSelects, ULWord(inAudioSystem),
570  sAudioMixerInputSelectMasks[inMixerInput],
571  sAudioMixerInputSelectShifts[inMixerInput]);
572 }
573 
575 {
576  outChannelPair = NTV2_AUDIO_CHANNEL_PAIR_INVALID;
577  if (!IsSupported(kDeviceCanDoAudioMixer))
578  return false; // No Audio Mixer -- shouldn't be calling this function
579  if (!NTV2_IS_VALID_AUDIO_MIXER_INPUT(inMixerInput))
580  return false; // Bad Mixer Input specified
581  if (NTV2_IS_AUDIO_MIXER_INPUT_MAIN(inMixerInput))
585  outChannelPair = NTV2_AudioChannel1_2; // Aux1/Aux2 always use 1&2
586  return true;
587 }
588 
590 {
591  if (!IsSupported(kDeviceCanDoAudioMixer))
592  return false; // No Audio Mixer -- shouldn't be calling this function
593  if (!NTV2_IS_AUDIO_MIXER_INPUT_MAIN(inMixerInput))
594  return false; // Can only change Main channel selection
595  if (!NTV2_IS_WITHIN_AUDIO_CHANNELS_1_TO_16(inChannelPair))
596  return false; // Only audio channels 1 thru 16 allowed
597  return WriteRegister (kRegAudioMixerChannelSelect, ULWord(inChannelPair),
599 }
600 
603 
604 bool CNTV2Card::GetAudioMixerInputGain (const NTV2AudioMixerInput inMixerInput, const NTV2AudioMixerChannel inChannel, ULWord & outGainValue)
605 {
606  outGainValue = 0;
607  if (!IsSupported(kDeviceCanDoAudioMixer))
608  return false; // No Audio Mixer -- shouldn't be calling this function
609  if (!NTV2_IS_VALID_AUDIO_MIXER_INPUT(inMixerInput))
610  return false; // Bad Mixer Input specified
611  if (!NTV2_IS_AUDIO_MIXER_CHANNELS_1_OR_2(inChannel))
612  return false; // Bad audio channel specified -- must be Ch1 or Ch2
613  return ReadRegister (inChannel == NTV2_AudioMixerChannel1
614  ? sAudioMixerInputGainCh1Regs[inMixerInput]
615  : sAudioMixerInputGainCh2Regs[inMixerInput], outGainValue);
616 }
617 
618 bool CNTV2Card::SetAudioMixerInputGain (const NTV2AudioMixerInput inMixerInput, const NTV2AudioMixerChannel inChannel, const ULWord inGainValue)
619 {
620  if (!IsSupported(kDeviceCanDoAudioMixer))
621  return false; // No Audio Mixer -- shouldn't be calling this function
622  if (!NTV2_IS_VALID_AUDIO_MIXER_INPUT(inMixerInput))
623  return false; // Bad Mixer Input specified
624  if (!NTV2_IS_AUDIO_MIXER_CHANNELS_1_OR_2(inChannel))
625  return false; // Bad audio channel specified -- must be Ch1 or Ch2
626  return WriteRegister(inChannel == NTV2_AudioMixerChannel1
627  ? sAudioMixerInputGainCh1Regs[inMixerInput]
628  : sAudioMixerInputGainCh2Regs[inMixerInput], inGainValue);
629 }
630 
632 {
633  outGainValue = 0;
634  if (!IsSupported(kDeviceCanDoAudioMixer))
635  return false; // No Audio Mixer -- shouldn't be calling this function
636  return ReadRegister (kRegAudioMixerOutGain, outGainValue);
637 }
638 
640 {
641  if (!IsSupported(kDeviceCanDoAudioMixer))
642  return false; // No Audio Mixer -- shouldn't be calling this function
643  WriteRegister(kRegAudioMixerOutLGain, inGainValue);
644  return WriteRegister(kRegAudioMixerOutRGain, inGainValue);
645 }
646 
648  vector<uint32_t> & outLevels)
649 {
654  outLevels.clear();
655  if (!IsSupported(kDeviceCanDoAudioMixer))
656  return false;
657 
658  // If caller specified empty channelPairs set, do "all" possible pairs...
659  NTV2AudioChannelPairs chanPairs;
660  if (inChannelPairs.empty())
661  {
663  chanPairs.insert(chPr); // Main supports Ch 1-16
664  }
665  else
666  chanPairs = inChannelPairs; // Non-empty set: do what the caller requested
667 
668  // Build a bulk register read...
669  NTV2RegisterReads regs;
670  std::set<ULWord> regsToRead;
671  for (NTV2AudioChannelPairsConstIter it(chanPairs.begin()); it != chanPairs.end(); ++it)
672  {
673  const NTV2AudioChannelPair chanPair(*it);
675  return false;
676  uint32_t regNum(gAudMxrMainOutLvlRegs[chanPair]);
677  regsToRead.insert(regNum);
678  } // for each audio channel pair
679  for (std::set<ULWord>::const_iterator it(regsToRead.begin()); it != regsToRead.end(); ++it)
680  regs.push_back(NTV2RegInfo(*it));
681 
682  // Read the level registers...
683  const bool result(ReadRegisters(regs));
684  if (result)
685  for (NTV2RegisterReadsConstIter it(regs.begin()); it != regs.end(); ++it)
686  {
687  ULWord rawLevels(it->IsValid() ? it->registerValue : 0);
688  outLevels.push_back(uint32_t((rawLevels & kRegMaskAudioMixerInputLeftLevel) >> kRegShiftAudioMixerInputLeftLevel));
689  outLevels.push_back(uint32_t((rawLevels & kRegMaskAudioMixerInputRightLevel) >> kRegShiftAudioMixerInputRightLevel));
690  }
691  else
692  while (outLevels.size() < chanPairs.size() * 2)
693  outLevels.push_back(0);
694  return result;
695 }
696 
698 {
699  outGainValue = 0;
700  if (!IsSupported(kDeviceHasRotaryEncoder))
701  return false; // No Rotary Encoder control
702  return ReadRegister (kRegRotaryEncoder, outGainValue, kRegMaskRotaryEncoderGain, kRegShiftRotaryEncoderGain);
703 }
704 
706 {
707  if (!IsSupported(kDeviceHasRotaryEncoder))
708  return false; // No Rotary Encoder control
709  return WriteRegister(kRegRotaryEncoder, inGainValue, kRegMaskRotaryEncoderGain, kRegShiftRotaryEncoderGain);
710 }
711 
714 
716 {
717  outMutes.reset();
718  if (!IsSupported(kDeviceCanDoAudioMixer))
719  return false; // No Audio Mixer -- shouldn't be calling this function
720  unsigned long ulongvalue(0);
722  return false;
723  outMutes = NTV2AudioChannelsMuted16(ulongvalue); // Hardware uses 1=mute 0=enabled
724  return true;
725 }
726 
728 {
729  if (!IsSupported(kDeviceCanDoAudioMixer))
730  return false; // No Audio Mixer -- shouldn't be calling this function
732 }
733 
735 {
736  outMutes.reset();
737  if (!IsSupported(kDeviceCanDoAudioMixer))
738  return false; // No Audio Mixer -- shouldn't be calling this function
739  if (!NTV2_IS_VALID_AUDIO_MIXER_INPUT(inMixerInput))
740  return false; // Bad Mixer Input specified
741  ULWord muteBits(0);
742  if (!ReadRegister(kRegAudioMixerMutes, muteBits, sAudioMixerInputMuteMasks[inMixerInput], sAudioMixerInputMuteShifts[inMixerInput]))
743  return false;
744  outMutes = NTV2AudioChannelsMuted16(muteBits);
745  return true;
746 }
747 
749 {
750  if (!IsSupported(kDeviceCanDoAudioMixer))
751  return false; // No Audio Mixer -- shouldn't be calling this function
752  if (!NTV2_IS_VALID_AUDIO_MIXER_INPUT(inMixerInput))
753  return false; // Bad Mixer Input specified
754  const ULWord muteBits(ULWord(inMutes.to_ulong()));
755  return WriteRegister (kRegAudioMixerMutes, muteBits, sAudioMixerInputMuteMasks[inMixerInput], sAudioMixerInputMuteShifts[inMixerInput]);
756 }
757 
758 
760  const NTV2AudioChannelPairs & inChannelPairs,
761  vector<uint32_t> & outLevels)
762 {
767  outLevels.clear();
768  if (!IsSupported(kDeviceCanDoAudioMixer))
769  return false;
770  if (!NTV2_IS_VALID_AUDIO_MIXER_INPUT(inMixerInput))
771  return false;
772 
773  // If caller specified empty channelPairs set, do "all" possible pairs...
774  NTV2AudioChannelPairs chanPairs;
775  if (inChannelPairs.empty())
776  {
777  if (!NTV2_IS_AUDIO_MIXER_INPUT_MAIN(inMixerInput))
778  chanPairs.insert(NTV2_AudioChannel1_2); // Aux1/Aux2 only support Ch1&2
779  else
781  chanPairs.insert(chPr); // Main supports Ch 1-16
782  }
783  else
784  chanPairs = inChannelPairs; // Non-empty set: do what the caller requested
785 
786  // Build a bulk register read...
787  NTV2RegisterReads regs;
788  std::set<ULWord> regsToRead;
789  for (NTV2AudioChannelPairsConstIter it(chanPairs.begin()); it != chanPairs.end(); ++it)
790  {
791  const NTV2AudioChannelPair chanPair(*it);
793  return false;
794  uint32_t regNum(gAudMxrMainInLvlRegs[chanPair]);
795  if (!NTV2_IS_AUDIO_MIXER_INPUT_MAIN(inMixerInput))
796  {
797  if (chanPair != NTV2_AudioChannel1_2)
798  return false; // Aux1 & Aux2 can only report Chan 1&2 levels
799  regNum = (inMixerInput == NTV2_AudioMixerInputAux1)
802  }
803  regsToRead.insert(regNum);
804  } // for each audio channel pair
805  for (std::set<ULWord>::const_iterator it(regsToRead.begin()); it != regsToRead.end(); ++it)
806  regs.push_back(NTV2RegInfo(*it));
807 
808  // Read the level registers...
809  const bool result(ReadRegisters(regs));
810  if (result)
811  for (NTV2RegisterReadsConstIter it(regs.begin()); it != regs.end(); ++it)
812  {
813  ULWord rawLevels(it->IsValid() ? it->registerValue : 0);
814  outLevels.push_back(uint32_t((rawLevels & kRegMaskAudioMixerInputLeftLevel) >> kRegShiftAudioMixerInputLeftLevel));
815  outLevels.push_back(uint32_t((rawLevels & kRegMaskAudioMixerInputRightLevel) >> kRegShiftAudioMixerInputRightLevel));
816  }
817  else
818  while (outLevels.size() < chanPairs.size() * 2)
819  outLevels.push_back(0);
820  return result;
821 }
822 
824 {
825  outSampleCount = 0;
827  return false;
828  outSampleCount = 1 << outSampleCount;
829  return true;
830 }
831 
833 {
834  if (!inSampleCount)
835  return false; // Must be > 0
836  if (inSampleCount > 0x00008000)
837  return false; // Must be <= 0x8000
838  ULWord result(0), sampleCount(inSampleCount);
839  while (sampleCount >>= 1)
840  ++result;
842 }
843 
844 
845 
847 {
849 
850  if (!GetHDMIOutControlReg(reg, inWhichHDMIOut))
851  return false;
852 
853  return WriteRegister (reg, ULWord(value), kRegMaskHDMIOutAudioCh, kRegShiftHDMIOutAudioCh);
854 }
855 
856 
858 {
860 
861  if (!GetHDMIOutControlReg(reg, inWhichHDMIOut))
862  return false;
863 
865 }
866 
867 
868 bool CNTV2Card::SetHDMIOutAudioSource2Channel (const NTV2AudioChannelPair inValue, const NTV2AudioSystem inAudioSystem, const NTV2Channel inWhichHDMIOut)
869 {
871  ULWord regOC(kRegHDMIOutControl);
872 
873  if (!NTV2_IS_VALID_AUDIO_CHANNEL_PAIR (inValue))
874  return false;
875 
876  if (GetNumSupported(kDeviceGetHDMIVersion) > 3)
877  {
878  if (!GetHDMIOutInputControlRegNum(regIC, inWhichHDMIOut))
879  return false;
880  if (!GetHDMIOutControlReg(regOC, inWhichHDMIOut))
881  return false;
882 
884  ULWord channelSelect = static_cast<ULWord>(inValue) % 4;
885  WriteRegister (regIC, inAudioSystem, kRegMaskHDMIOutSourceSelect, kRegShiftHDMIOutSourceSelect);
886  WriteRegister (regOC, bankSelect, kRegMaskHDMIOut8ChGroupSelect, kRegShiftHDMIOut8ChGroupSelect);
887  WriteRegister (regIC, channelSelect, kRegMaskHDMIOutAudio2ChannelSelect, kRegShiftHDMIOutAudio2ChannelSelect);
888  return SetHDMIOutAudioChannels(NTV2_HDMIAudio2Channels, inWhichHDMIOut);
889  }
890  else
891  {
892  const ULWord encoding ((ULWord (inAudioSystem) << 4) | inValue);
894  }
895 }
896 
897 
898 bool CNTV2Card::GetHDMIOutAudioSource2Channel (NTV2AudioChannelPair & outValue, NTV2AudioSystem & outAudioSystem, const NTV2Channel inWhichHDMIOut)
899 {
901  ULWord regOC(kRegHDMIOutControl);
902  bool result = false;
903 
904  if (GetNumSupported(kDeviceGetHDMIVersion) > 3)
905  {
906  if (!GetHDMIOutInputControlRegNum(regIC, inWhichHDMIOut))
907  return false;
908  if (!GetHDMIOutControlReg(regOC, inWhichHDMIOut))
909  return false;
910 
911  ULWord engineSelect (0), channelSelect(0), bankSelect(0);
912  result = ReadRegister(regIC, engineSelect, kRegMaskHDMIOutSourceSelect, kRegShiftHDMIOutSourceSelect);
913  if (result)
914  {
915  outAudioSystem = NTV2AudioSystem(engineSelect);
916  result = ReadRegister(regIC, channelSelect, kRegMaskHDMIOutAudio2ChannelSelect, kRegShiftHDMIOutAudio2ChannelSelect);
917  result = ReadRegister(regOC, bankSelect, kRegMaskHDMIOut8ChGroupSelect, kRegShiftHDMIOut8ChGroupSelect);
918  outValue = NTV2AudioChannelPair((bankSelect == 0 ? 0 : 4) + channelSelect);
919  }
920  }
921  else
922  {
923  ULWord encoding (0);
925  if (result)
926  {
927  outValue = NTV2AudioChannelPair(encoding & 0x7);
928  outAudioSystem = NTV2AudioSystem(encoding >> 4);
929  }
930  }
931  return result;
932 }
933 
934 
935 bool CNTV2Card::SetHDMIOutAudioSource8Channel (const NTV2Audio8ChannelSelect inValue, const NTV2AudioSystem inAudioSystem, const NTV2Channel inWhichHDMIOut)
936 {
938  ULWord regOC(kRegHDMIOutControl);
939 
940  if (!NTV2_IS_VALID_AUDIO_CHANNEL_OCTET (inValue))
941  return false;
942 
943  if (GetNumSupported(kDeviceGetHDMIVersion) > 3)
944  {
945  if (!GetHDMIOutInputControlRegNum(regIC, inWhichHDMIOut))
946  return false;
947  if (!GetHDMIOutControlReg(regOC, inWhichHDMIOut))
948  return false;
949 
951  WriteRegister (regIC, inAudioSystem, kRegMaskHDMIOutSourceSelect, kRegShiftHDMIOutSourceSelect);
952  WriteRegister (regOC, channelSelect, kRegMaskHDMIOut8ChGroupSelect, kRegShiftHDMIOut8ChGroupSelect);
953  return SetHDMIOutAudioChannels(NTV2_HDMIAudio8Channels, inWhichHDMIOut);
954  }
955  else
956  {
957  ULWord encoding (0);
958  ULWord ch (ULWord (inAudioSystem) << 2);
959  if (inValue == NTV2_AudioChannel1_8)
960  encoding = (ch + NTV2_AudioChannel1_4) | ((ch + NTV2_AudioChannel5_8) << 4);
961  else
962  encoding = (ch + NTV2_AudioChannel9_12) | ((ch + NTV2_AudioChannel13_16) << 4);
963 
965  }
966 }
967 
968 
969 bool CNTV2Card::GetHDMIOutAudioSource8Channel (NTV2Audio8ChannelSelect & outValue, NTV2AudioSystem & outAudioSystem, const NTV2Channel inWhichHDMIOut)
970 {
972  ULWord regOC(kRegHDMIOutControl);
973  bool result = false;
974 
975  if (GetNumSupported(kDeviceGetHDMIVersion) > 3)
976  {
977  if (!GetHDMIOutInputControlRegNum(regIC, inWhichHDMIOut))
978  return false;
979  if (!GetHDMIOutControlReg(regOC, inWhichHDMIOut))
980  return false;
981 
982  ULWord engineSelect (0), channelSelect(0);
983  result = ReadRegister(regOC, channelSelect, kRegMaskHDMIOut8ChGroupSelect, kRegShiftHDMIOut8ChGroupSelect);
984  if (result)
985  {
986  outValue = channelSelect == 1 ? NTV2_AudioChannel9_16 : NTV2_AudioChannel1_8;
987  result = ReadRegister(regIC, engineSelect, kRegMaskHDMIOutSourceSelect, kRegShiftHDMIOutSourceSelect);
988  outAudioSystem = static_cast <NTV2AudioSystem> (engineSelect);
989  }
990  }
991  else
992  {
993  ULWord encoding (0);
995  if (result)
996  {
997  if ((encoding & 0x3) == static_cast <ULWord> (NTV2_AudioChannel1_4))
998  outValue = NTV2_AudioChannel1_8;
999  else
1000  outValue = NTV2_AudioChannel9_16;
1001 
1002  outAudioSystem = static_cast <NTV2AudioSystem> ((encoding & 0xC) >> 2);
1003  }
1004  }
1005  return result;
1006 }
1007 
1008 
1009 bool CNTV2Card::SetHDMIOutAudioRate (const NTV2AudioRate inNewValue, const NTV2Channel inWhichHDMIOut)
1010 {
1012 
1013  if (!GetHDMIOutInputControlRegNum(reg, inWhichHDMIOut))
1014  return false;
1015 
1016  return WriteRegister (reg, static_cast <ULWord> (inNewValue), kRegMaskHDMIOutAudioRate, kRegShiftHDMIOutAudioRate);
1017 }
1018 
1019 
1020 bool CNTV2Card::GetHDMIOutAudioRate (NTV2AudioRate & outValue, const NTV2Channel inWhichHDMIOut)
1021 {
1023 
1024  if (!GetHDMIOutInputControlRegNum(reg, inWhichHDMIOut))
1025  return false;
1026 
1028 }
1029 
1030 
1031 bool CNTV2Card::SetHDMIOutAudioFormat (const NTV2AudioFormat inNewValue, const NTV2Channel inWhichHDMIOut)
1032 {
1034 
1035  if (!GetHDMIOutControlReg(reg, inWhichHDMIOut))
1036  return false;
1037 
1038  return WriteRegister (reg, static_cast <ULWord> (inNewValue), kRegMaskHDMIOutAudioFormat, kRegShiftHDMIOutAudioFormat);
1039 }
1040 
1041 
1042 bool CNTV2Card::GetHDMIOutAudioFormat (NTV2AudioFormat & outValue, const NTV2Channel inWhichHDMIOut)
1043 {
1045 
1046  if (!GetHDMIOutControlReg(reg, inWhichHDMIOut))
1047  return false;
1048 
1050 }
1051 
1052 
1053 bool CNTV2Card::SetAudioOutputMonitorSource (const NTV2AudioChannelPair inChannelPair, const NTV2AudioSystem inAudioSystem)
1054 {
1055  if (!NTV2_IS_WITHIN_AUDIO_CHANNELS_1_TO_16(inChannelPair))
1056  return false;
1057  if (!NTV2_IS_VALID_AUDIO_SYSTEM(inAudioSystem))
1058  return false;
1059  const ULWord encoding ((ULWord(inAudioSystem) << 4) | inChannelPair);
1060  return WriteRegister (kRegAudioOutputSourceMap, encoding, kRegMaskMonitorSource, kRegShiftMonitorSource);
1061 }
1062 
1063 
1065 {
1066  ULWord encoding (0);
1067  bool result = ReadRegister (kRegAudioOutputSourceMap, encoding, kRegMaskMonitorSource, kRegShiftMonitorSource);
1068  if (result)
1069  {
1070  outChannelPair = NTV2AudioChannelPair(encoding & 0xF);
1071  outAudioSystem = NTV2AudioSystem(encoding >> 4);
1072  }
1073  return result;
1074 }
1075 
1076 bool CNTV2Card::StartAudioOutput (const NTV2AudioSystem inAudioSystem, const bool inWaitForVBI)
1077 {
1078  if (inAudioSystem >= NTV2_NUM_AUDIOSYSTEMS)
1079  return false; // Bad AudioSystem
1080  const ULWord audioCtrlRegNum(gAudioSystemToAudioControlRegNum[inAudioSystem]);
1081  if (inWaitForVBI)
1082  {
1083  if (!IsSupported(kDeviceAudioCanWaitForVBI))
1084  return false; // Caller requested wait-til-VBI, but firmware doesn't support it
1085  // Set or clear the start-at-VBI bit...
1086  if (!WriteRegister(audioCtrlRegNum, inWaitForVBI ? 1UL : 0UL, kRegMaskOutputStartAtVBI, kRegShiftOutputStartAtVBI))
1087  return false;
1088  }
1089  if (!WriteRegister (audioCtrlRegNum, 0, kRegMaskResetAudioOutput, kRegShiftResetAudioOutput))
1090  return false;
1091 #if 1
1092  // Now that this audio system is reading from SDRAM, see if its buffer is colliding with other device SDRAM activity...
1093  ULWordSequence badRgns;
1094  SDRAMAuditor auditor;
1095  auditor.AssessDevice(*this, /*ignoreStoppedAudioSystemBuffers*/true); // Only care about running audio systems
1096  auditor.GetBadRegions(badRgns); // Receive the interfering memory regions
1097  for (size_t ndx(0); ndx < badRgns.size(); ndx++)
1098  { const ULWord rgnInfo(badRgns.at(ndx));
1099  const UWord startBlk(rgnInfo >> 16), numBlks(UWord(rgnInfo & 0x0000FFFF));
1100  NTV2StringSet tags;
1101  auditor.GetTagsForFrameIndex (startBlk, tags);
1102  const string infoStr (aja::join(tags, ", "));
1103  ostringstream acLabel; acLabel << "Aud" << DEC(inAudioSystem+1); // Search for label e.g. "Aud2"
1104  if (infoStr.find(acLabel.str()) != string::npos)
1105  { ostringstream warning;
1106  if (numBlks > 1)
1107  warning << "8MB Frms " << DEC0N(startBlk,3) << "-" << DEC0N(startBlk+numBlks-1,3);
1108  else
1109  warning << "8MB Frm " << DEC0N(startBlk,3);
1110  AUDWARN("Aud" << DEC(inAudioSystem+1) << " memory overlap/interference: " << warning.str() << ": " << infoStr);
1111  }
1112  } // for each "bad" region
1113 #endif
1114  return true;
1115 } // StartAudioOutput
1116 
1118 {
1119  return inAudioSystem < NTV2_NUM_AUDIOSYSTEMS
1121 }
1122 
1123 bool CNTV2Card::IsAudioOutputRunning (const NTV2AudioSystem inAudioSystem, bool & outIsRunning)
1124 {
1125  bool isStopped (true);
1126  bool result (inAudioSystem < NTV2_NUM_AUDIOSYSTEMS
1129  if (result)
1130  outIsRunning = !isStopped;
1131  return result;
1132 }
1133 
1134 
1135 bool CNTV2Card::SetAudio20BitMode (const NTV2AudioSystem inAudioSystem, const bool inEnable)
1136 {
1137  return IsSupported(kDeviceCanDoIP)
1138  && inAudioSystem < NTV2_NUM_AUDIOSYSTEMS
1139  && WriteRegister (gAudioSystemToAudioControlRegNum[inAudioSystem], inEnable ? 1 : 0, kRegMask20BitMode, kRegShift20BitMode);
1140 }
1141 
1142 
1143 bool CNTV2Card::GetAudio20BitMode (const NTV2AudioSystem inAudioSystem, bool & outEnable)
1144 {
1145  return IsSupported(kDeviceCanDoIP)
1146  && inAudioSystem < NTV2_NUM_AUDIOSYSTEMS
1148 }
1149 
1150 
1151 bool CNTV2Card::SetAudioOutputPause (const NTV2AudioSystem inAudioSystem, const bool inEnable)
1152 {
1153  return inAudioSystem < NTV2_NUM_AUDIOSYSTEMS
1154  && WriteRegister (gAudioSystemToAudioControlRegNum[inAudioSystem], inEnable ? 1 : 0, kRegMaskPauseAudio, kRegShiftPauseAudio);
1155 }
1156 
1157 
1158 bool CNTV2Card::GetAudioOutputPause (const NTV2AudioSystem inAudioSystem, bool & outEnable)
1159 {
1160  return inAudioSystem < NTV2_NUM_AUDIOSYSTEMS
1162 }
1163 
1164 
1165 bool CNTV2Card::StartAudioInput (const NTV2AudioSystem inAudioSystem, const bool inWaitForVBI)
1166 {
1167  if (inAudioSystem >= NTV2_NUM_AUDIOSYSTEMS)
1168  return false; // Bad AudioSystem
1169  const ULWord audioCtrlRegNum(gAudioSystemToAudioControlRegNum[inAudioSystem]);
1170  if (inWaitForVBI)
1171  {
1172  if (!IsSupported(kDeviceAudioCanWaitForVBI))
1173  return false; // Caller requested wait-til-VBI, but firmware doesn't support it
1174  // Set or clear the start-at-VBI bit...
1175  if (!WriteRegister(audioCtrlRegNum, inWaitForVBI ? 1UL : 0UL, kRegMaskInputStartAtVBI, kRegShiftInputStartAtVBI))
1176  return false;
1177  }
1178  if (!WriteRegister (audioCtrlRegNum, 0, kRegMaskResetAudioInput, kRegShiftResetAudioInput))
1179  return false;
1180 #if 1
1181  // Now that this audio system is writing into SDRAM, see if its buffer is colliding with other device SDRAM activity...
1182  ULWordSequence badRgns;
1183  SDRAMAuditor auditor;
1184  auditor.AssessDevice(*this, /*ignoreStoppedAudioSystemBuffers*/true); // Only care about running audio systems
1185  auditor.GetBadRegions(badRgns); // Receive the interfering memory regions
1186  for (size_t ndx(0); ndx < badRgns.size(); ndx++)
1187  { const ULWord rgnInfo(badRgns.at(ndx));
1188  const UWord startBlk(rgnInfo >> 16), numBlks(UWord(rgnInfo & 0x0000FFFF));
1189  NTV2StringSet tags;
1190  auditor.GetTagsForFrameIndex (startBlk, tags);
1191  const string infoStr (aja::join(tags, ", "));
1192  ostringstream acLabel; acLabel << "Aud" << DEC(inAudioSystem+1); // Search for label e.g. "Aud2"
1193  if (infoStr.find(acLabel.str()) != string::npos)
1194  { ostringstream warning;
1195  if (numBlks > 1)
1196  warning << "8MB Frms " << DEC0N(startBlk,3) << "-" << DEC0N(startBlk+numBlks-1,3);
1197  else
1198  warning << "8MB Frm " << DEC0N(startBlk,3);
1199  AUDWARN("Aud" << DEC(inAudioSystem+1) << " memory overlap/interference: " << warning.str() << ": " << infoStr);
1200  }
1201  } // for each "bad" region
1202 #endif
1203  return true;
1204 } // StartAudioInput
1205 
1206 
1207 bool CNTV2Card::StopAudioInput (const NTV2AudioSystem inAudioSystem)
1208 {
1209  return inAudioSystem < NTV2_NUM_AUDIOSYSTEMS
1211 }
1212 
1213 
1214 bool CNTV2Card::IsAudioInputRunning (const NTV2AudioSystem inAudioSystem, bool & outIsRunning)
1215 {
1216  bool isStopped (true);
1217  bool result (inAudioSystem < NTV2_NUM_AUDIOSYSTEMS &&
1220  if (result)
1221  outIsRunning = !isStopped;
1222  return result;
1223 }
1224 
1225 
1226 bool CNTV2Card::SetAudioCaptureEnable (const NTV2AudioSystem inAudioSystem, const bool inEnable)
1227 {
1228  return inAudioSystem < NTV2_NUM_AUDIOSYSTEMS
1229  && WriteRegister (gAudioSystemToAudioControlRegNum[inAudioSystem], inEnable ? 1 : 0, kRegMaskCaptureEnable, kRegShiftCaptureEnable);
1230 }
1231 
1232 
1233 bool CNTV2Card::GetAudioCaptureEnable (const NTV2AudioSystem inAudioSystem, bool & outEnable)
1234 {
1235  return inAudioSystem < NTV2_NUM_AUDIOSYSTEMS
1237 }
1238 
1239 
1240 bool CNTV2Card::SetAudioPlayCaptureModeEnable (const NTV2AudioSystem inAudioSystem, const bool inEnable)
1241 {
1242  return inAudioSystem < NTV2_NUM_AUDIOSYSTEMS
1243  && WriteRegister (kRegGlobalControl2, inEnable ? 1 : 0, gAudioPlayCaptureModeMasks[inAudioSystem], gAudioPlayCaptureModeShifts[inAudioSystem]);
1244 }
1245 
1246 
1247 bool CNTV2Card::GetAudioPlayCaptureModeEnable (const NTV2AudioSystem inAudioSystem, bool & outEnable)
1248 {
1249  outEnable = false;
1250  return inAudioSystem < NTV2_NUM_AUDIOSYSTEMS
1252 }
1253 
1254 
1255 bool CNTV2Card::SetAudioInputDelay (const NTV2AudioSystem inAudioSystem, const ULWord inDelay)
1256 {
1257  return IsSupported(kDeviceCanDoAudioDelay)
1258  && inAudioSystem < NTV2_NUM_AUDIOSYSTEMS
1259  && WriteRegister (gAudioDelayRegisterNumbers [inAudioSystem], inDelay, kRegMaskAudioInDelay, kRegShiftAudioInDelay);
1260 }
1261 
1262 
1263 bool CNTV2Card::GetAudioInputDelay (const NTV2AudioSystem inAudioSystem, ULWord & outDelay)
1264 {
1265  return IsSupported(kDeviceCanDoAudioDelay)
1266  && inAudioSystem < NTV2_NUM_AUDIOSYSTEMS
1267  && ReadRegister (gAudioDelayRegisterNumbers[inAudioSystem], outDelay, kRegMaskAudioInDelay, kRegShiftAudioInDelay);
1268 }
1269 
1270 
1271 bool CNTV2Card::SetAudioOutputDelay (const NTV2AudioSystem inAudioSystem, const ULWord inDelay)
1272 {
1273  return IsSupported(kDeviceCanDoAudioDelay)
1274  && inAudioSystem < NTV2_NUM_AUDIOSYSTEMS
1275  && WriteRegister (gAudioDelayRegisterNumbers[inAudioSystem], inDelay, kRegMaskAudioOutDelay, kRegShiftAudioOutDelay);
1276 }
1277 
1278 
1279 bool CNTV2Card::GetAudioOutputDelay (const NTV2AudioSystem inAudioSystem, ULWord & outDelay)
1280 {
1281  return IsSupported(kDeviceCanDoAudioDelay)
1282  && inAudioSystem < NTV2_NUM_AUDIOSYSTEMS
1283  && ReadRegister (gAudioDelayRegisterNumbers[inAudioSystem], outDelay, kRegMaskAudioOutDelay, kRegShiftAudioOutDelay);
1284 }
1285 
1286 
1287 bool CNTV2Card::SetAudioPCMControl (const NTV2AudioSystem inAudioSystem, const bool inNonPCM)
1288 {
1289  return inAudioSystem < NTV2_NUM_AUDIOSYSTEMS
1290  && WriteRegister (gAudioSystemToSrcSelectRegNum[inAudioSystem], inNonPCM ? 1 : 0, BIT(17), 17);
1291 }
1292 
1293 
1294 bool CNTV2Card::GetAudioPCMControl (const NTV2AudioSystem inAudioSystem, bool & outIsNonPCM)
1295 {
1296  return inAudioSystem < NTV2_NUM_AUDIOSYSTEMS
1297  && CNTV2DriverInterface::ReadRegister (gAudioSystemToSrcSelectRegNum[inAudioSystem], outIsNonPCM, BIT(17), 17);
1298 }
1299 
1300 
1301 bool CNTV2Card::SetAudioPCMControl (const NTV2AudioSystem inAudioSystem, const NTV2AudioChannelPair inChannelSelect, bool inNonPCM)
1302 {
1303  return IsSupported(kDeviceCanDoPCMControl)
1304  && inAudioSystem < NTV2_NUM_AUDIOSYSTEMS
1305  && NTV2_IS_VALID_AUDIO_CHANNEL_PAIR(inChannelSelect)
1306  && WriteRegister(gAudioEngineChannelPairToFieldInformation[inAudioSystem][inChannelSelect].pcmControlReg,
1307  inNonPCM ? 1 : 0,
1308  gAudioEngineChannelPairToFieldInformation[inAudioSystem][inChannelSelect].pcmControlMask,
1309  gAudioEngineChannelPairToFieldInformation[inAudioSystem][inChannelSelect].pcmControlShift);
1310 }
1311 
1312 
1313 bool CNTV2Card::SetAudioPCMControl (const NTV2AudioSystem inAudioSystem, const NTV2AudioChannelPairs & inNonPCMChannelPairs)
1314 {
1315  if (!IsSupported(kDeviceCanDoPCMControl) || inAudioSystem >= NTV2_NUM_AUDIOSYSTEMS)
1316  return false;
1317 
1318  bool result (true);
1319  for (NTV2AudioChannelPair chanPair (NTV2_AudioChannel1_2); NTV2_IS_VALID_AUDIO_CHANNEL_PAIR (chanPair); chanPair = NTV2AudioChannelPair (chanPair + 1))
1320  {
1321  if (NTV2_IS_EXTENDED_AUDIO_CHANNEL_PAIR (chanPair))
1322  break; // Extended audio channels not yet supported
1323 
1324  const bool isNonPCM (inNonPCMChannelPairs.find (chanPair) != inNonPCMChannelPairs.end ());
1325  result = WriteRegister (gAudioEngineChannelPairToFieldInformation[inAudioSystem][chanPair].pcmControlReg, isNonPCM ? 1 : 0,
1326  gAudioEngineChannelPairToFieldInformation[inAudioSystem][chanPair].pcmControlMask,
1327  gAudioEngineChannelPairToFieldInformation[inAudioSystem][chanPair].pcmControlShift);
1328  if (!result)
1329  break;
1330  }
1331  return result;
1332 }
1333 
1334 
1335 bool CNTV2Card::GetAudioPCMControl (const NTV2AudioSystem inAudioSystem, const NTV2AudioChannelPair inChannelSelect, bool & outIsNonPCM)
1336 {
1337  return IsSupported(kDeviceCanDoPCMControl)
1338  && inAudioSystem < NTV2_NUM_AUDIOSYSTEMS
1339  && NTV2_IS_VALID_AUDIO_CHANNEL_PAIR(inChannelSelect)
1340  && CNTV2DriverInterface::ReadRegister (gAudioEngineChannelPairToFieldInformation[inAudioSystem][inChannelSelect].pcmControlReg,
1341  outIsNonPCM,
1342  gAudioEngineChannelPairToFieldInformation[inAudioSystem][inChannelSelect].pcmControlMask,
1343  gAudioEngineChannelPairToFieldInformation[inAudioSystem][inChannelSelect].pcmControlShift);
1344 }
1345 
1346 
1347 bool CNTV2Card::GetAudioPCMControl (const NTV2AudioSystem inAudioSystem, NTV2AudioChannelPairs & outNonPCMChannelPairs)
1348 {
1349  ULWord numAudioChannels (0);
1350  bool isNonPCM (false);
1351 
1352  outNonPCMChannelPairs.clear ();
1353  if (inAudioSystem >= NTV2_NUM_AUDIOSYSTEMS)
1354  return false; // no such audio system on this device
1355  if (!GetNumberAudioChannels (numAudioChannels, inAudioSystem))
1356  return false; // fail
1357 
1358  const NTV2AudioChannelPair maxPair (NTV2AudioChannelPair(numAudioChannels/2));
1359  if (!GetAudioPCMControl (inAudioSystem, isNonPCM))
1360  return false; // fail
1361 
1362  if (isNonPCM) // this global mode overrides per-channel PCM control
1363  {
1364  for (UWord chPair (0); chPair <= maxPair; chPair++)
1365  outNonPCMChannelPairs.insert (NTV2AudioChannelPair (chPair));
1366  return true; // done
1367  }
1368 
1369  if (IsSupported(kDeviceCanDoPCMControl))
1370  {
1371  ULWord regVal (0);
1372  if (!ReadRegister (inAudioSystem < NTV2_AUDIOSYSTEM_5 ? kRegPCMControl4321 : kRegPCMControl8765, regVal))
1373  return false;
1375  if (regVal & BIT(inAudioSystem * 8 + chanPair))
1376  outNonPCMChannelPairs.insert (chanPair);
1377  }
1378  return true;
1379 }
1380 
1381 
1382 // NTV2_AUDIOSYSTEM_1 NTV2_AUDIOSYSTEM_2 NTV2_AUDIOSYSTEM_3 NTV2_AUDIOSYSTEM_4
1384 // NTV2_AUDIOSYSTEM_5 NTV2_AUDIOSYSTEM_6 NTV2_AUDIOSYSTEM_7 NTV2_AUDIOSYSTEM_8
1386 
1387 // NTV2_AUDIOSYSTEM_1 NTV2_AUDIOSYSTEM_2 NTV2_AUDIOSYSTEM_3 NTV2_AUDIOSYSTEM_4
1388 static const unsigned sAudioDetectGroups [] = { 0, 1, 0, 1,
1389 // NTV2_AUDIOSYSTEM_5 NTV2_AUDIOSYSTEM_6 NTV2_AUDIOSYSTEM_7 NTV2_AUDIOSYSTEM_8
1390  0, 1, 2, 3 };
1391 
1392 bool CNTV2Card::IsAudioChannelPairPresent (const NTV2AudioSystem inAudioSystem, const NTV2AudioChannelPair inChannelPair, bool & outIsPresent)
1393 {
1394  NTV2AudioChannelPairs activeChannelPairs;
1395  outIsPresent = false;
1396  if (!GetDetectedAudioChannelPairs (inAudioSystem, activeChannelPairs))
1397  return false;
1398  if (activeChannelPairs.find (inChannelPair) != activeChannelPairs.end ())
1399  outIsPresent = true;
1400  return true;
1401 }
1402 
1403 
1404 bool CNTV2Card::GetDetectedAudioChannelPairs (const NTV2AudioSystem inAudioSystem, NTV2AudioChannelPairs & outDetectedChannelPairs)
1405 {
1406  outDetectedChannelPairs.clear ();
1407  if (inAudioSystem >= NTV2_NUM_AUDIOSYSTEMS)
1408  return false;
1409 
1410  ULWord detectBits (0);
1411  if (!ReadRegister (sAudioDetectRegs[inAudioSystem], detectBits))
1412  return false;
1413 
1414  const unsigned bitGroup (sAudioDetectGroups[inAudioSystem]);
1416  if (detectBits & BIT(bitGroup * 8 + chanPair))
1417  outDetectedChannelPairs.insert (chanPair);
1418  return true;
1419 }
1420 
1421 
1423 {
1424  uint32_t valLo8(0), valHi8(0);
1425  outDetectedChannelPairs.clear ();
1426  if (!IsSupported(kDeviceCanDoAESAudioIn))
1427  return false;
1428  if (!ReadRegister(kRegInputStatus, valLo8)) // Reg 22, bits 24..27
1429  return false;
1430  if (!ReadRegister(kRegAud1SourceSelect, valHi8)) // Reg 25, bits 28..31
1431  return false;
1432 
1433  const uint32_t detectBits (((valLo8 >> 24) & 0x0000000F) | ((valHi8 >> 24) & 0x000000F0));
1434  for (NTV2AudioChannelPair chPair (NTV2_AudioChannel1_2); chPair < NTV2_AudioChannel15_16; chPair = NTV2AudioChannelPair(chPair+1))
1435  if (!(detectBits & BIT(chPair))) // bit set means "not connected"
1436  outDetectedChannelPairs.insert(chPair);
1437  return true;
1438 }
1439 
1440 
1441 bool CNTV2Card::SetSuspendHostAudio (const bool inIsSuspended)
1442 {
1443  return WriteRegister (kVRegSuspendSystemAudio, ULWord(inIsSuspended));
1444 }
1445 
1446 
1447 bool CNTV2Card::GetSuspendHostAudio (bool & outIsSuspended)
1448 {
1450 }
1451 
1452 
1453 // GetAESOutputSource / SetAESOutputSource:
1454 //
1455 // Register 190 (kRegAudioOutputSourceMap) does the mapping by audio group (audio channel quads).
1456 // Each of the least-significant 4 nibbles correspond to AES output audio channel quads:
1457 //
1458 // RegMask NTV2Audio4ChannelSelect
1459 // ========== =======================
1460 // 0x0000000F NTV2_AudioChannel1_4
1461 // 0x000000F0 NTV2_AudioChannel5_8
1462 // 0x00000F00 NTV2_AudioChannel9_12
1463 // 0x0000F000 NTV2_AudioChannel13_16
1464 //
1465 // The value of the nibble determines the source:
1466 // Value NTV2AudioSystem NTV2Audio4ChannelSelect
1467 // ===== =============== =======================
1468 // 0x0: NTV2_AUDIOSYSTEM_1 NTV2_AudioChannel1_4
1469 // 0x1: NTV2_AUDIOSYSTEM_1 NTV2_AudioChannel5_8
1470 // 0x2: NTV2_AUDIOSYSTEM_1 NTV2_AudioChannel9_12
1471 // 0x3: NTV2_AUDIOSYSTEM_1 NTV2_AudioChannel13_16
1472 // 0x4: NTV2_AUDIOSYSTEM_2 NTV2_AudioChannel1_4
1473 // 0x5: NTV2_AUDIOSYSTEM_2 NTV2_AudioChannel5_8
1474 // 0x6: NTV2_AUDIOSYSTEM_2 NTV2_AudioChannel9_12
1475 // 0x7: NTV2_AUDIOSYSTEM_2 NTV2_AudioChannel13_16
1476 // 0x8: NTV2_AUDIOSYSTEM_3 NTV2_AudioChannel1_4
1477 // 0x9: NTV2_AUDIOSYSTEM_3 NTV2_AudioChannel5_8
1478 // 0xA: NTV2_AUDIOSYSTEM_3 NTV2_AudioChannel9_12
1479 // 0xB: NTV2_AUDIOSYSTEM_3 NTV2_AudioChannel13_16
1480 // 0xC: NTV2_AUDIOSYSTEM_4 NTV2_AudioChannel1_4
1481 // 0xD: NTV2_AUDIOSYSTEM_4 NTV2_AudioChannel5_8
1482 // 0xE: NTV2_AUDIOSYSTEM_4 NTV2_AudioChannel9_12
1483 // 0xF: NTV2_AUDIOSYSTEM_4 NTV2_AudioChannel13_16
1484 
1485 static const unsigned gAESChannelMappingShifts [4] = {0, 4, 8, 12};
1486 
1487 
1488 bool CNTV2Card::GetAESOutputSource (const NTV2Audio4ChannelSelect inAESAudioChannels, NTV2AudioSystem & outSrcAudioSystem, NTV2Audio4ChannelSelect & outSrcAudioChannels)
1489 {
1490  const ULWord numAESAudioOutputChannels (GetNumSupported(kDeviceGetNumAESAudioOutputChannels));
1491  const ULWord maxNumAudioChannelsForQuad ((inAESAudioChannels + 1) * 4);
1492 
1493  outSrcAudioSystem = NTV2_AUDIOSYSTEM_INVALID;
1494  outSrcAudioChannels = NTV2_AUDIO_CHANNEL_QUAD_INVALID;
1495 
1496  if (numAESAudioOutputChannels < 4)
1497  return false; // Fail, device doesn't support AES output
1498  if (maxNumAudioChannelsForQuad > numAESAudioOutputChannels)
1499  return false; // Fail, illegal inAESAudioChannels value
1500 
1501  ULWord regValue (0);
1502  if (!ReadRegister (kRegAudioOutputSourceMap, regValue))
1503  return false; // Failed in ReadRegister
1504 
1505  regValue = (regValue >> gAESChannelMappingShifts[inAESAudioChannels]) & 0x0000000F;
1506  outSrcAudioSystem = NTV2AudioSystem(regValue / 4);
1507  NTV2_ASSERT (NTV2_IS_VALID_AUDIO_SYSTEM (outSrcAudioSystem));
1508 
1509  outSrcAudioChannels = NTV2Audio4ChannelSelect(regValue % 4);
1510  NTV2_ASSERT (NTV2_IS_NORMAL_AUDIO_CHANNEL_QUAD (outSrcAudioChannels));
1511  return true;
1512 }
1513 
1514 
1515 bool CNTV2Card::SetAESOutputSource (const NTV2Audio4ChannelSelect inAESAudioChannels, const NTV2AudioSystem inSrcAudioSystem, const NTV2Audio4ChannelSelect inSrcAudioChannels)
1516 {
1517  const ULWord nibble (ULWord(inSrcAudioSystem) * 4 + ULWord(inSrcAudioChannels));
1518  return WriteRegister (kRegAudioOutputSourceMap, // reg
1519  nibble, // value
1520  ULWord(0xF << gAESChannelMappingShifts[inAESAudioChannels]), // mask
1521  gAESChannelMappingShifts[inAESAudioChannels]); // shift
1522 }
1523 
1524 
1525 static NTV2AudioChannelPairs BitMasksToNTV2AudioChannelPairs (const ULWord inBitMask, const ULWord inExtendedBitMask)
1526 {
1527  NTV2AudioChannelPairs result;
1528  if (inBitMask)
1529  for (NTV2AudioChannelPair channelPair (NTV2_AudioChannel1_2); channelPair < NTV2_AudioChannel17_18; channelPair = NTV2AudioChannelPair (channelPair + 1))
1530  if (inBitMask & BIT (channelPair))
1531  result.insert (channelPair);
1532  if (inExtendedBitMask)
1533  for (NTV2AudioChannelPair channelPair (NTV2_AudioChannel17_18); channelPair < NTV2_MAX_NUM_AudioChannelPair; channelPair = NTV2AudioChannelPair (channelPair + 1))
1534  if (inExtendedBitMask & BIT (channelPair))
1535  result.insert (channelPair);
1536  return result;
1537 }
1538 
1539 
1540 static inline NTV2RegisterNumber GetNonPCMDetectRegisterNumber (const NTV2Channel inSDIInputChannel, const bool inIsExtended = false)
1541 {
1542  return NTV2RegisterNumber (kRegFirstNonPCMAudioDetectRegister + inSDIInputChannel * 2 + (inIsExtended ? 1 : 0));
1543 }
1544 
1545 
1546 bool CNTV2Card::InputAudioChannelPairHasPCM (const NTV2Channel inSDIInputChannel, const NTV2AudioChannelPair inAudioChannelPair, bool & outHasPCM)
1547 {
1548  if (!NTV2_IS_VALID_AUDIO_CHANNEL_PAIR (inAudioChannelPair))
1549  return false;
1550  NTV2AudioChannelPairs withPCMs;
1551  if (!GetInputAudioChannelPairsWithPCM (inSDIInputChannel, withPCMs))
1552  return false;
1553 
1554  outHasPCM = withPCMs.find (inAudioChannelPair) != withPCMs.end (); // Test set membership
1555  return true;
1556 }
1557 
1558 
1560 {
1561  outPCMPairs.clear ();
1562  if (!IsSupported(kDeviceCanDoPCMDetection))
1563  return false;
1564  if (!NTV2_IS_VALID_CHANNEL (inSDIInputChannel))
1565  return false;
1566  if (ULWord(inSDIInputChannel) >= GetNumSupported(kDeviceGetNumVideoInputs))
1567  return false;
1568 
1569  // Read channel pair bitmask registers...
1570  const ULWord numChannels (GetNumSupported(kDeviceGetMaxAudioChannels));
1571  const bool isExtended (numChannels > 16);
1572  const NTV2RegisterNumber regNum (::GetNonPCMDetectRegisterNumber (inSDIInputChannel));
1573  ULWord mask (0);
1574  ULWord extMask (0);
1575  if (!ReadRegister (regNum, mask))
1576  return false;
1577  if (isExtended)
1578  if (!ReadRegister (regNum + 1, extMask))
1579  return false;
1580 
1581  // Convert bitmasks to set of with-PCM pairs...
1582  outPCMPairs = ::BitMasksToNTV2AudioChannelPairs (~mask, isExtended ? ~extMask : 0);
1583  return true;
1584 }
1585 
1586 
1588 {
1589  outNonPCMPairs.clear ();
1590  if (!IsSupported(kDeviceCanDoPCMDetection))
1591  return false;
1592  if (!NTV2_IS_VALID_CHANNEL (inSDIInputChannel))
1593  return false;
1594  if (ULWord(inSDIInputChannel) >= GetNumSupported(kDeviceGetNumVideoInputs))
1595  return false;
1596 
1597  // Read channel pair bitmask registers...
1598  const ULWord numChannels (GetNumSupported(kDeviceGetMaxAudioChannels));
1599  const bool isExtended (numChannels > 16);
1600  const NTV2RegisterNumber regNum (::GetNonPCMDetectRegisterNumber (inSDIInputChannel));
1601  ULWord mask (0);
1602  ULWord extMask (0);
1603  if (!ReadRegister (regNum, mask))
1604  return false;
1605  if (isExtended)
1606  if (!ReadRegister (regNum + 1, extMask))
1607  return false;
1608 
1609  // Convert bitmasks to set of non-PCM pairs...
1610  outNonPCMPairs = ::BitMasksToNTV2AudioChannelPairs (mask, isExtended ? extMask : 0);
1611  return true;
1612 }
1613 
1614 // GetSDIOutputAudioEnabled, SetSDIOutputAudioEnabled:
1615 // The audio HANC disable bit actually controls the SDI Output, not the Audio System
1616 // (They probably should've been put in the SDIOut widget control registers.)
1617 // Also thanks to "legacy", bits 13 & 15 control an even-numbered and odd-numbered, respectively, SDI output:
1618 // Thus the ctrl reg of AudSys1 controls SDI1 & SDI2; AudSys3 controls SDIOut3 & SDIOut4; AudSys5 for SDI5 & SDI6; etc...
1619 // The control registers of Audio Systems 2, 4, 6 & 8 ignore bits 13 & 15.
1622 
1623 bool CNTV2Card::GetSDIOutputAudioEnabled (const NTV2Channel inSDIOutputSpigot, bool & outIsEnabled)
1624 {
1625  outIsEnabled = true; // presume normal
1626  if (!NTV2_IS_VALID_CHANNEL (inSDIOutputSpigot))
1627  return false;
1628  if (ULWord(inSDIOutputSpigot) >= GetNumSupported(kDeviceGetNumVideoOutputs))
1629  return false;
1630 
1631  ULWord value (0);
1632  if (!ReadRegister (kAudCtrlRegsForSDIOutputs[inSDIOutputSpigot], value,
1635  return false;
1636  outIsEnabled = value ? false : true; // Bit sense is 1=disabled, 0=enabled/normal
1637  return true;
1638 }
1639 
1640 bool CNTV2Card::SetSDIOutputAudioEnabled (const NTV2Channel inSDIOutputSpigot, const bool & inEnable)
1641 {
1642  if (!NTV2_IS_VALID_CHANNEL (inSDIOutputSpigot))
1643  return false;
1644  if (ULWord(inSDIOutputSpigot) >= GetNumSupported(kDeviceGetNumVideoOutputs))
1645  return false;
1646 
1647  return WriteRegister (kAudCtrlRegsForSDIOutputs[inSDIOutputSpigot], inEnable ? 0 : 1,
1650 }
1651 
1652 
1653 bool CNTV2Card::GetAudioOutputEraseMode (const NTV2AudioSystem inAudioSystem, bool & outEraseModeEnabled)
1654 {
1655  outEraseModeEnabled = false;
1656  if (!NTV2_IS_VALID_AUDIO_SYSTEM(inAudioSystem))
1657  return false;
1658  if (UWord(inAudioSystem) >= GetNumSupported(kDeviceGetNumBufferedAudioSystems))
1659  return false;
1660  ULWord regValue(0);
1661  if (!ReadRegister (gAudioSystemToSrcSelectRegNum[inAudioSystem], regValue))
1662  return false;
1663  outEraseModeEnabled = (regValue & kRegMaskAudioAutoErase) ? true : false;
1664  return true;
1665 }
1666 
1667 
1668 bool CNTV2Card::SetAudioOutputEraseMode (const NTV2AudioSystem inAudioSystem, const bool & inEraseModeEnabled)
1669 {
1670  if (!NTV2_IS_VALID_AUDIO_SYSTEM (inAudioSystem))
1671  return false;
1672  if (UWord(inAudioSystem) >= GetNumSupported(kDeviceGetNumBufferedAudioSystems))
1673  return false;
1674  return WriteRegister (gAudioSystemToSrcSelectRegNum[inAudioSystem], inEraseModeEnabled ? 1 : 0, kRegMaskAudioAutoErase, kRegShiftAudioAutoErase);
1675 }
1676 
1677 bool CNTV2Card::SetAnalogAudioTransmitEnable (const NTV2Audio4ChannelSelect inChannelQuad, const bool inXmitEnable)
1678 {
1679  // Reg 108 (kRegGlobalControl3) has two bits for controlling XLR direction: BIT(0) for XLRs 1-4, BIT(1) for XLRs 5-8
1680  if (!IsSupported(kDeviceHasBiDirectionalAnalogAudio))
1681  return false; // unsupported
1682  if (inChannelQuad > NTV2_AudioChannel5_8)
1683  return false; // NTV2_AudioChannel1_4 & NTV2_AudioChannel5_8 only
1684  return WriteRegister (kRegGlobalControl3, inXmitEnable ? 0 : 1, // 0 == xmit 1 == recv
1686  ULWord(inChannelQuad));
1687 }
1688 
1689 bool CNTV2Card::GetAnalogAudioTransmitEnable (const NTV2Audio4ChannelSelect inChannelQuad, bool & outXmitEnabled)
1690 {
1691  outXmitEnabled = false;
1692  // Reg 108 (kRegGlobalControl3) has two bits for controlling XLR direction: BIT(0) for XLRs 1-4, BIT(1) for XLRs 5-8
1693  if (!IsSupported(kDeviceHasBiDirectionalAnalogAudio))
1694  return false; // unsupported
1695  if (inChannelQuad > NTV2_AudioChannel5_8)
1696  return false; // NTV2_AudioChannel1_4 & NTV2_AudioChannel5_8 only
1697  if (!CNTV2DriverInterface::ReadRegister (kRegGlobalControl3, outXmitEnabled, // false == xmit true == recv
1699  ULWord(inChannelQuad)))
1700  return false;
1701  outXmitEnabled = !outXmitEnabled; // Flip the sense, we want xmit == true, recv == false
1702  return true;
1703 }
1704 
1705 bool CNTV2Card::SetMultiLinkAudioMode (const NTV2AudioSystem inAudioSystem, const bool inEnable)
1706 {
1707  if (!IsSupported(kDeviceCanDoMultiLinkAudio))
1708  return false;
1709  return WriteRegister(gAudioSystemToAudioControlRegNum[inAudioSystem], inEnable ? 1 : 0, kRegMaskMultiLinkAudio, kRegShiftMultiLinkAudio);
1710 }
1711 
1712 bool CNTV2Card::GetMultiLinkAudioMode (const NTV2AudioSystem inAudioSystem, bool & outEnabled)
1713 {
1714  outEnabled = false;
1715  if (!IsSupported(kDeviceCanDoMultiLinkAudio))
1716  return false;
1718 }
1719 
1720 #if !defined(NTV2_DEPRECATE_16_1)
1722  {
1723  if (inConfig > NTV2_AnalogAudioIO_8In)
1724  return false;
1725  return SetAnalogAudioTransmitEnable (NTV2_AudioChannel1_4, inConfig == NTV2_AnalogAudioIO_8Out || inConfig == NTV2_AnalogAudioIO_4Out_4In)
1726  && SetAnalogAudioTransmitEnable (NTV2_AudioChannel5_8, inConfig == NTV2_AnalogAudioIO_8Out || inConfig == NTV2_AnalogAudioIO_4In_4Out);
1727  }
1728 
1730  {
1731  bool xlr14Xmit(false), xlr58Xmit(false);
1732  if (!GetAnalogAudioTransmitEnable (NTV2_AudioChannel1_4, xlr14Xmit))
1733  return false;
1734  if (!GetAnalogAudioTransmitEnable (NTV2_AudioChannel5_8, xlr58Xmit))
1735  return false;
1736  if (xlr14Xmit && xlr58Xmit)
1737  outConfig = NTV2_AnalogAudioIO_8Out;
1738  else if (xlr14Xmit && !xlr58Xmit)
1739  outConfig = NTV2_AnalogAudioIO_4Out_4In;
1740  else if (!xlr14Xmit && xlr58Xmit)
1741  outConfig = NTV2_AnalogAudioIO_4In_4Out;
1742  else
1743  outConfig = NTV2_AnalogAudioIO_8In;
1744  return true;
1745  }
1746 #endif // !defined(NTV2_DEPRECATE_16_1)
1747 
1748 bool CNTV2Card::GetAudioOutputAESSyncModeBit (const NTV2AudioSystem inAudioSystem, bool & outAESSyncModeBitSet)
1749 {
1750  if (!NTV2_IS_VALID_AUDIO_SYSTEM(inAudioSystem))
1751  return false;
1752  if (UWord(inAudioSystem) >= GetNumSupported(kDeviceGetNumBufferedAudioSystems))
1753  return false;
1754  ULWord regValue(0);
1755  if (!ReadRegister (gAudioSystemToSrcSelectRegNum[inAudioSystem], regValue, BIT(18), 18))
1756  return false;
1757  outAESSyncModeBitSet = regValue ? true : false;
1758  return true;
1759 }
1760 
1761 bool CNTV2Card::SetAudioOutputAESSyncModeBit (const NTV2AudioSystem inAudioSystem, const bool & inAESSyncModeBitSet)
1762 {
1763  if (!NTV2_IS_VALID_AUDIO_SYSTEM(inAudioSystem))
1764  return false;
1765  if (UWord(inAudioSystem) >= GetNumSupported(kDeviceGetNumBufferedAudioSystems))
1766  return false;
1767  return WriteRegister(gAudioSystemToSrcSelectRegNum[inAudioSystem], inAESSyncModeBitSet?1:0, BIT(18), 18);
1768 }
1769 
1770 bool CNTV2Card::GetRawAudioTimer (ULWord & outValue, const NTV2AudioSystem inAudioSystem)
1771 {
1772  if (!NTV2_IS_VALID_AUDIO_SYSTEM(inAudioSystem))
1773  return false;
1774  return ReadRegister(kRegAud1Counter, outValue);
1775 }
1776 
1778 {
1779  return IsSupported(kDeviceCanDoBreakoutBoard)
1781 }
1782 
1783 bool CNTV2Card::GetAudioMemoryOffset (const ULWord inOffsetBytes, ULWord & outAbsByteOffset,
1784  const NTV2AudioSystem inAudioSystem, const bool inCaptureBuffer)
1785 {
1786  outAbsByteOffset = 0;
1787  const NTV2DeviceID deviceID(GetDeviceID());
1788  if (ULWord(inAudioSystem) >= GetNumSupported(kDeviceGetNumBufferedAudioSystems))
1789  return false; // Invalid audio system
1790 
1791  if (IsSupported(kDeviceCanDoStackedAudio))
1792  {
1793  const ULWord EIGHT_MEGABYTES (0x800000);
1794  const ULWord memSize (GetNumSupported(kDeviceGetActiveMemorySize));
1795  const ULWord engineOffset (memSize - EIGHT_MEGABYTES * ULWord(inAudioSystem+1));
1796  outAbsByteOffset = inOffsetBytes + engineOffset;
1797  }
1798  else
1799  {
1802  if (!GetFrameGeometry (fg, NTV2Channel(inAudioSystem)) || !GetFrameBufferFormat (NTV2Channel(inAudioSystem), fbf))
1803  return false;
1804 
1805  const ULWord audioFrameBuffer (::NTV2DeviceGetNumberFrameBuffers(deviceID, fg, fbf) - 1);
1806  outAbsByteOffset = inOffsetBytes + audioFrameBuffer * ::NTV2DeviceGetFrameBufferSize(deviceID, fg, fbf);
1807  }
1808 
1809  if (inCaptureBuffer) // Capture mode?
1810  { ULWord rdBufOffset(0x400000); // 4MB
1811  GetAudioReadOffset (rdBufOffset, inAudioSystem);
1812  outAbsByteOffset += rdBufOffset; // Add offset to point to capture buffer
1813  }
1814  return true;
1815 }
1816 
1817 #ifdef MSWindows
1818  #pragma warning(default: 4800)
1819 #endif
virtual bool GetAudioPCMControl(const NTV2AudioSystem inAudioSystem, bool &outIsNonPCM)
Answers whether or not all outgoing audio channel pairs are currently being flagged as non-PCM for th...
Definition: ntv2audio.cpp:1294
Everything needed to call CNTV2Card::ReadRegister or CNTV2Card::WriteRegister functions.
This selects the Audio Mixer&#39;s 1st Auxiliary input.
Definition: ntv2enums.h:3257
virtual bool GetAudioWrapAddress(ULWord &outWrapAddress, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
For the given Audio System, answers with the wrap address, the threshold at which input/record or out...
Definition: ntv2audio.cpp:433
virtual bool GetAudioOutputPause(const NTV2AudioSystem inAudioSystem, bool &outIsPaused)
Answers if the device&#39;s Audio System is currently paused or not.
Definition: ntv2audio.cpp:1158
NTV2AudioSystem
Used to identify an Audio System on an NTV2 device. See Audio System Operation for more information...
Definition: ntv2enums.h:3895
virtual bool SetAudioAnalogLevel(const NTV2AudioLevel value, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Definition: ntv2audio.cpp:280
virtual bool GetHDMIOutAudioRate(NTV2AudioRate &outValue, const NTV2Channel inWhichHDMIOut=NTV2_CHANNEL1)
Answers with the HDMI output&#39;s current audio rate.
Definition: ntv2audio.cpp:1020
virtual bool SetMultiLinkAudioMode(const NTV2AudioSystem inAudioSystem, const bool inEnable)
Sets the multi-link audio mode for the given audio system.
Definition: ntv2audio.cpp:1705
bool GetBadRegions(ULWordSequence &outBlks) const
Answers with the list of colliding and illegal memory regions.
Definition: ntv2card.h:6973
virtual bool SetHDMIOutAudioSource2Channel(const NTV2AudioChannelPair inNewValue, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1, const NTV2Channel inWhichHDMIOut=NTV2_CHANNEL1)
Sets the HDMI output&#39;s 2-channel audio source.
Definition: ntv2audio.cpp:868
virtual bool GetAudioLoopBack(NTV2AudioLoopBack &outMode, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Answers if NTV2AudioLoopBack mode is currently on or off for the given NTV2AudioSystem.
Definition: ntv2audio.cpp:321
virtual bool SetAudioLoopBack(const NTV2AudioLoopBack inMode, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Enables or disables NTV2AudioLoopBack mode for the given NTV2AudioSystem.
Definition: ntv2audio.cpp:300
virtual bool GetDetectedAESChannelPairs(NTV2AudioChannelPairs &outDetectedChannelPairs)
Answers which AES/EBU audio channel pairs are present on the device.
Definition: ntv2audio.cpp:1422
static const ULWord gAudioPlayCaptureModeMasks[]
Definition: ntv2audio.cpp:37
NTV2AudioBufferSize
Represents the size of the audio buffer used by a device audio system for storing captured samples or...
Definition: ntv2enums.h:1914
This selects audio channels 5 thru 8.
Definition: ntv2enums.h:3274
#define DEC0N(__x__, __n__)
virtual bool EnableBOBAnalogAudioIn(bool inEnable)
Enables breakout board analog audio XLR inputs.
Definition: ntv2audio.cpp:1777
virtual bool GetAudioMixerInputLevels(const NTV2AudioMixerInput inMixerInput, const NTV2AudioChannelPairs &inChannelPairs, std::vector< uint32_t > &outLevels)
Answers with the Audio Mixer&#39;s current audio input levels.
Definition: ntv2audio.cpp:759
NTV2FrameBufferFormat
Identifies a particular video frame buffer pixel format. See Device Frame Buffer Formats for details...
Definition: ntv2enums.h:219
#define BIT(_x_)
Definition: ajatypes.h:578
The number of AES/EBU audio output channels on the device.
PCM_CONTROL_INFO(ULWord regNum, ULWord mask, ULWord shift)
Definition: ntv2audio.cpp:58
virtual bool GetAudioOutputAESSyncModeBit(const NTV2AudioSystem inAudioSystem, bool &outAESSyncModeBitSet)
Answers with the current state of the AES Sync Mode bit for the given Audio System&#39;s output...
Definition: ntv2audio.cpp:1748
Obtain audio samples from the device AES inputs, if available.
Definition: ntv2enums.h:2008
virtual bool GetHDMIOutAudioChannels(NTV2HDMIAudioChannels &outValue, const NTV2Channel inWhichHDMIOut=NTV2_CHANNEL1)
Answers with the audio channel count for the given HDMI output (2 or 8).
Definition: ntv2audio.cpp:857
bool AssessDevice(CNTV2Card &inDevice, const bool inIgnoreStoppedAudioBuffers=(0))
Assesses the given device.
Definition: ntv2card.cpp:610
Declares the AJADebug class.
static const ULWord sAudioDetectRegs[]
Definition: ntv2audio.cpp:1383
Obtain audio samples from the device HDMI input, if available.
Definition: ntv2enums.h:2010
virtual bool GetAudioInputDelay(const NTV2AudioSystem inAudioSystem, ULWord &outDelay)
Answers with the audio input delay for the given Audio System on the device.
Definition: ntv2audio.cpp:1263
virtual bool SetAudioCaptureEnable(const NTV2AudioSystem inAudioSystem, const bool inEnable)
Enables or disables the writing of incoming audio into the given Audio System&#39;s capture buffer...
Definition: ntv2audio.cpp:1226
virtual bool SetAudioMixerOutputChannelsMute(const NTV2AudioChannelsMuted16 inMutes)
Mutes or enables the individual output audio channels of the Audio Mixer.
Definition: ntv2audio.cpp:727
Audits an NTV2 device&#39;s SDRAM utilization, and can report contiguous regions of SDRAM, whether unused/free, those being read/written by AutoCirculate, those being read/written by non-AutoCirculating FrameStores, those that are in conflict (AutoCirculate, FrameStore and/or Audio collisions), plus invalid/out-of-bounds regions being accessed.
Definition: ntv2card.h:6908
The number of independent Audio Systems on the device.
virtual bool SetAudioOutputEraseMode(const NTV2AudioSystem inAudioSystem, const bool &inEraseModeEnabled)
Enables or disables output erase mode for the given Audio System, which, when enabled, automatically writes zeroes into the audio output buffer behind the output read head.
Definition: ntv2audio.cpp:1668
NTV2AnalogAudioIO
Definition: ntv2enums.h:2232
virtual bool GetAudioSystemInputSource(const NTV2AudioSystem inAudioSystem, NTV2AudioSource &outAudioSource, NTV2EmbeddedAudioInput &outEmbeddedSource)
Answers with the device&#39;s current NTV2AudioSource (and also possibly its NTV2EmbeddedAudioInput) for ...
Definition: ntv2audio.cpp:515
static const ULWord kAudCtrlRegsForSDIOutputs[]
Definition: ntv2audio.cpp:1620
virtual bool GetHDMIOutAudioSource2Channel(NTV2AudioChannelPair &outValue, NTV2AudioSystem &outAudioSystem, const NTV2Channel inWhichHDMIOut=NTV2_CHANNEL1)
Answers with the HDMI output&#39;s current 2-channel audio source.
Definition: ntv2audio.cpp:898
virtual bool GetAudioRate(NTV2AudioRate &outRate, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Returns the current NTV2AudioRate for the given Audio System.
Definition: ntv2audio.cpp:226
virtual bool GetEncodedAudioMode(NTV2EncodedAudioMode &outValue, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Definition: ntv2audio.cpp:338
True if device can detect which audio channel pairs are not carrying PCM (Pulse Code Modulation) audi...
virtual bool GetAudioMixerOutputGain(ULWord &outGainValue)
Answers with the current gain setting for the Audio Mixer&#39;s output.
Definition: ntv2audio.cpp:631
virtual bool ReadAudioSource(ULWord &outValue, const NTV2Channel inChannel=NTV2_CHANNEL1)
Definition: ntv2audio.cpp:480
virtual bool SetAudioOutputDelay(const NTV2AudioSystem inAudioSystem, const ULWord inDelay)
Sets the audio output delay for the given Audio System on the device.
Definition: ntv2audio.cpp:1271
virtual bool SetAudioOutputMonitorSource(const NTV2AudioChannelPair inChannelPair, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Sets the audio monitor output source to a specified audio system and channel pair. The audio output monitor is typically a pair of RCA jacks (white + red) and/or a headphone jack.
Definition: ntv2audio.cpp:1053
virtual bool GetInputAudioChannelPairsWithoutPCM(const NTV2Channel inSDIInputConnector, NTV2AudioChannelPairs &outChannelPairs)
For the given SDI input (specified as a channel number), returns the set of audio channel pairs that ...
Definition: ntv2audio.cpp:1587
std::bitset< 16 > NTV2AudioChannelsMuted16
Per-audio-channel mute state for up to 16 audio channels.
Obtain audio samples from the audio that&#39;s embedded in the video HANC.
Definition: ntv2enums.h:2007
NTV2EmbeddedAudioClock
This enum value determines/states the device audio clock reference source. It was important to set th...
Definition: ntv2enums.h:1990
#define NTV2_IS_EXTENDED_AUDIO_CHANNEL_PAIR(__p__)
Definition: ntv2enums.h:3206
True if device has SFP connectors.
#define NTV2_IS_VALID_AUDIO_CHANNEL_OCTET(__p__)
Definition: ntv2enums.h:3344
This selects audio channels 9 thru 16.
Definition: ntv2enums.h:3323
static const ULWord gAudioRateHighShift[]
Definition: ntv2audio.cpp:51
virtual bool GetAudioOutputDelay(const NTV2AudioSystem inAudioSystem, ULWord &outDelay)
Answers with the audio output delay for the given Audio System on the device.
Definition: ntv2audio.cpp:1279
Definition: json.hpp:5362
NTV2HDMIAudioChannels
Indicates or specifies the HDMI audio channel count.
Definition: ntv2enums.h:3667
virtual bool SetAudioRate(const NTV2AudioRate inRate, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Sets the NTV2AudioRate for the given Audio System.
Definition: ntv2audio.cpp:205
virtual bool IsAudioInputRunning(const NTV2AudioSystem inAudioSystem, bool &outIsRunning)
Answers whether or not the capture side of the given NTV2AudioSystem is currently running...
Definition: ntv2audio.cpp:1214
virtual bool IsAudioChannelPairPresent(const NTV2AudioSystem inAudioSystem, const NTV2AudioChannelPair inChannelPair, bool &outIsPresent)
Answers whether or not the given NTV2AudioChannelPair in the given NTV2AudioSystem on the device is p...
Definition: ntv2audio.cpp:1392
Declares common audio macros and structs used in the SDK.
static const ULWord sAudioMixerInputMuteShifts[]
Definition: ntv2audio.cpp:713
#define false
#define NTV2_IS_AUDIO_MIXER_CHANNELS_1_OR_2(__p__)
Definition: ntv2enums.h:3248
uint32_t ULWord
Definition: ajatypes.h:223
Embeds SDI input source audio into the data stream.
Definition: ntv2enums.h:2031
NTV2AudioFormat
Definition: ntv2enums.h:1951
NTV2Channel
These enum values are mostly used to identify a specific widget_framestore. They&#39;re also commonly use...
Definition: ntv2enums.h:1357
True if Audio System(s) support an adjustable delay.
True if device supports an AJA breakout board. (New in SDK 17.0)
virtual bool SetAnalogAudioIOConfiguration(const NTV2AnalogAudioIO inConfig)
Definition: ntv2audio.cpp:1721
std::set< NTV2AudioChannelPair > NTV2AudioChannelPairs
A set of distinct NTV2AudioChannelPair values.
virtual bool SetHDMIOutAudioChannels(const NTV2HDMIAudioChannels inNewValue, const NTV2Channel inWhichHDMIOut=NTV2_CHANNEL1)
Sets the audio channel count to use for the given HDMI output.
Definition: ntv2audio.cpp:846
static const ULWord sAudioMixerInputMuteMasks[]
Definition: ntv2audio.cpp:712
This identifies the 5th Audio System.
Definition: ntv2enums.h:3901
True if device supports grouped audio system control.
virtual bool SetAudioMixerOutputGain(const ULWord inGainValue)
Sets the gain for the output of the Audio Mixer.
Definition: ntv2audio.cpp:639
virtual bool StartAudioOutput(const NTV2AudioSystem inAudioSystem, const bool inWaitForVBI=(0))
Starts the playout side of the given NTV2AudioSystem, reading outgoing audio samples from the Audio S...
Definition: ntv2audio.cpp:1076
#define NTV2_ASSERT(_expr_)
Definition: ajatypes.h:476
The number of SDI video outputs on the device.
#define NTV2_AUDIO_WRAPADDRESS
Obtain audio samples from the device analog input(s), if available.
Definition: ntv2enums.h:2009
NTV2RegWritesConstIter NTV2RegisterReadsConstIter
This selects audio channels 15 and 16 (Group 4 channels 3 and 4)
Definition: ntv2enums.h:3140
The total number of audio systems on the device, including host audio and mixer audio systems...
True if device can mark specific audio channel pairs as not carrying PCM (Pulse Code Modulation) audi...
virtual bool SetAudioPlayCaptureModeEnable(const NTV2AudioSystem inAudioSystem, const bool inEnable)
Enables or disables a special mode for the given Audio System whereby its embedder and deembedder bot...
Definition: ntv2audio.cpp:1240
virtual bool SetAudioSystemInputSource(const NTV2AudioSystem inAudioSystem, const NTV2AudioSource inAudioSource, const NTV2EmbeddedAudioInput inEmbeddedInput)
Sets the audio source for the given NTV2AudioSystem on the device.
Definition: ntv2audio.cpp:485
ULWord pcmControlShift
Definition: ntv2audio.cpp:57
virtual bool SetHDMIOutAudioRate(const NTV2AudioRate inNewValue, const NTV2Channel inWhichHDMIOut=NTV2_CHANNEL1)
Sets the HDMI output&#39;s audio rate.
Definition: ntv2audio.cpp:1009
This selects audio channels 1 thru 8.
Definition: ntv2enums.h:3322
static const unsigned sAudioDetectGroups[]
Definition: ntv2audio.cpp:1388
#define true
virtual bool GetAudioMixerOutputLevels(const NTV2AudioChannelPairs &inChannelPairs, std::vector< uint32_t > &outLevels)
Answers with the Audio Mixer&#39;s current audio output levels.
Definition: ntv2audio.cpp:647
virtual bool IsAudioOutputRunning(const NTV2AudioSystem inAudioSystem, bool &outIsRunning)
Answers whether or not the playout side of the given NTV2AudioSystem is currently running...
Definition: ntv2audio.cpp:1123
NTV2DeviceID
Identifies a specific AJA NTV2 device model number. The NTV2DeviceID is actually the PROM part number...
Definition: ntv2enums.h:20
virtual bool SetAudioMixerInputChannelSelect(const NTV2AudioMixerInput inMixerInput, const NTV2AudioChannelPair inChannelPair)
Specifies the Audio Channel Pair that will drive the given input of the Audio Mixer.
Definition: ntv2audio.cpp:589
virtual bool GetAudioMixerInputChannelSelect(const NTV2AudioMixerInput inMixerInput, NTV2AudioChannelPair &outChannelPair)
Answers with the Audio Channel Pair that&#39;s currently driving the given input of the Audio Mixer...
Definition: ntv2audio.cpp:574
virtual bool GetAudioMixerOutputChannelsMute(NTV2AudioChannelsMuted16 &outMutes)
Answers with a std::bitset that indicates which output audio channels of the Audio Mixer are currentl...
Definition: ntv2audio.cpp:715
virtual bool GetAudioCaptureEnable(const NTV2AudioSystem inAudioSystem, bool &outEnable)
Answers whether or not the Audio System is configured to write captured audio samples into device aud...
Definition: ntv2audio.cpp:1233
virtual bool GetAudioAnalogLevel(NTV2AudioLevel &outValue, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Definition: ntv2audio.cpp:290
static const ULWord gChannelToAudioOutLastAddrRegNum[]
Definition: ntv2audio.cpp:34
ULWord pcmControlReg
Definition: ntv2audio.cpp:55
True if device has attached breakout board. (New in SDK 17.0)
virtual bool ReadRegister(const ULWord inRegNum, ULWord &outValue, const ULWord inMask=0xFFFFFFFF, const ULWord inShift=0)
Reads all or part of the 32-bit contents of a specific register (real or virtual) on the AJA device...
virtual bool StartAudioInput(const NTV2AudioSystem inAudioSystem, const bool inWaitForVBI=(0))
Starts the capture side of the given NTV2AudioSystem, writing incoming audio samples into the Audio S...
Definition: ntv2audio.cpp:1165
NTV2AudioLoopBack
This enum value determines/states if an audio output embedder will embed silence (zeroes) or de-embed...
Definition: ntv2enums.h:2028
virtual bool GetHDMIOutAudioFormat(NTV2AudioFormat &outValue, const NTV2Channel inWhichHDMIOut=NTV2_CHANNEL1)
Answers with the HDMI output&#39;s current audio format.
Definition: ntv2audio.cpp:1042
This selects audio channels 1 thru 4.
Definition: ntv2enums.h:3273
#define NTV2_IS_AUDIO_MIXER_INPUT_MAIN(__p__)
Definition: ntv2enums.h:3264
This selects audio channels 1 and 2 (Group 1 channels 1 and 2)
Definition: ntv2enums.h:3133
True if device uses a "stacked" arrangement of its audio buffers.
This selects audio channels 9 thru 12.
Definition: ntv2enums.h:3275
virtual bool GetHDMIOutAudioSource8Channel(NTV2Audio8ChannelSelect &outValue, NTV2AudioSystem &outAudioSystem, const NTV2Channel inWhichHDMIOut=NTV2_CHANNEL1)
Answers with the HDMI output&#39;s current 8-channel audio source.
Definition: ntv2audio.cpp:969
NTV2AudioChannelPair
Identifies a pair of audio channels.
Definition: ntv2enums.h:3131
virtual bool GetAnalogAudioIOConfiguration(NTV2AnalogAudioIO &outConfig)
Definition: ntv2audio.cpp:1729
virtual bool ReadAudioLastIn(ULWord &outValue, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
For the given Audio System, answers with the byte offset to the last byte of the latest chunk of 4-by...
Definition: ntv2audio.cpp:465
virtual bool SetEmbeddedAudioInput(const NTV2EmbeddedAudioInput inEmbeddedSource, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Sets the embedded (SDI) audio source for the given NTV2AudioSystem on the device. ...
Definition: ntv2audio.cpp:346
NTV2RegWrites NTV2RegisterReads
virtual bool GetAudioOutputMonitorSource(NTV2AudioChannelPair &outChannelPair, NTV2AudioSystem &outAudioSystem)
Answers with the current audio monitor source. The audio output monitor is typically a pair of RCA ja...
Definition: ntv2audio.cpp:1064
virtual bool GetAudioOutputEraseMode(const NTV2AudioSystem inAudioSystem, bool &outEraseModeEnabled)
Answers with the current state of the audio output erase mode for the given Audio System...
Definition: ntv2audio.cpp:1653
virtual bool InputAudioChannelPairHasPCM(const NTV2Channel inSDIInputConnector, const NTV2AudioChannelPair inAudioChannelPair, bool &outIsPCM)
For the given SDI input (specified as a channel number), answers if the specified audio channel pair ...
Definition: ntv2audio.cpp:1546
The maximum number of audio channels that a single Audio System can support on the device...
std::set< NTV2AudioSystem > NTV2AudioSystemSet
A set of distinct NTV2AudioSystem values. New in SDK 16.2.
virtual bool GetAudioBufferSize(NTV2AudioBufferSize &outSize, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Retrieves the size of the input or output audio buffer being used for a given Audio System on the AJA...
Definition: ntv2audio.cpp:268
#define AUDWARN(__x__)
Definition: ntv2audio.cpp:22
static const ULWord gAudioRateHighMask[]
Definition: ntv2audio.cpp:48
#define NTV2_AUDIO_WRAPADDRESS_BIG
static const ULWord sAudioMixerInputGainCh1Regs[]
Definition: ntv2audio.cpp:601
virtual bool WriteAudioSource(const ULWord inValue, const NTV2Channel inChannel=NTV2_CHANNEL1)
Definition: ntv2audio.cpp:481
virtual bool SetAudio20BitMode(const NTV2AudioSystem inAudioSystem, const bool inEnable)
Enables or disables 20-bit mode for the NTV2AudioSystem.
Definition: ntv2audio.cpp:1135
NTV2AudioLevel
Definition: ntv2enums.h:2313
virtual bool GetRawAudioTimer(ULWord &outValue, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Answers with the current value of the 48kHz audio clock counter.
Definition: ntv2audio.cpp:1770
virtual bool GetAnalogAudioTransmitEnable(const NTV2Audio4ChannelSelect inChannelQuad, bool &outEnabled)
Answers whether or not the specified bidirectional XLR audio connectors are collectively acting as in...
Definition: ntv2audio.cpp:1689
virtual bool GetDetectedAudioChannelPairs(const NTV2AudioSystem inAudioSystem, NTV2AudioChannelPairs &outDetectedChannelPairs)
Answers which audio channel pairs are present in the given Audio System&#39;s input stream.
Definition: ntv2audio.cpp:1404
virtual bool GetAudioPlayCaptureModeEnable(const NTV2AudioSystem inAudioSystem, bool &outEnable)
Answers whether or not the device&#39;s Audio System is currently operating in a special mode in which it...
Definition: ntv2audio.cpp:1247
ULWord NTV2DeviceGetNumberFrameBuffers(NTV2DeviceID id, NTV2FrameGeometry fg, NTV2FrameBufferFormat fbf)
virtual bool GetAESOutputSource(const NTV2Audio4ChannelSelect inAESAudioChannels, NTV2AudioSystem &outSrcAudioSystem, NTV2Audio4ChannelSelect &outSrcAudioChannels)
Answers with the current audio source for a given quad of AES audio output channels. By default, at power-up, for AJA devices that support AES audio output, the content of AES audio output channels 1/2/3/4 reflect what&#39;s being output from audio channels 1/2/3/4 from NTV2_AUDIOSYSTEM_1, likewise with audio channels 5/6/7/8, etc.
Definition: ntv2audio.cpp:1488
#define NTV2_IS_VALID_AUDIO_LOOPBACK(_x_)
Definition: ntv2enums.h:2035
static const ULWord gAudioPlayCaptureModeShifts[]
Definition: ntv2audio.cpp:40
#define NTV2_IS_VALID_AUDIO_MIXER_INPUT(__p__)
Definition: ntv2enums.h:3263
#define NTV2_IS_VALID_CHANNEL(__x__)
Definition: ntv2enums.h:1371
virtual bool SetEncodedAudioMode(const NTV2EncodedAudioMode value, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Definition: ntv2audio.cpp:330
virtual bool GetAudioMixerLevelsSampleCount(ULWord &outSampleCount)
Answers with the Audio Mixer&#39;s current sample count used for measuring audio levels.
Definition: ntv2audio.cpp:823
virtual bool GetAudioReadOffset(ULWord &outReadOffset, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
For the given Audio System, answers with the byte offset from the start of the audio buffer to the fi...
Definition: ntv2audio.cpp:449
virtual bool SetAudioBufferSize(const NTV2AudioBufferSize inValue, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Changes the size of the audio buffer that is used for a given Audio System in the AJA device...
Definition: ntv2audio.cpp:249
virtual bool ReadAudioLastOut(ULWord &outValue, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
For the given Audio System, answers with the byte offset of the tail end of the last chunk of audio s...
Definition: ntv2audio.cpp:472
virtual bool GetNumberAudioChannels(ULWord &outNumChannels, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Returns the current number of audio channels being captured or played by a given Audio System on the ...
Definition: ntv2audio.cpp:180
static NTV2AudioChannelPairs BitMasksToNTV2AudioChannelPairs(const ULWord inBitMask, const ULWord inExtendedBitMask)
Definition: ntv2audio.cpp:1525
This selects audio channels 13 thru 16.
Definition: ntv2enums.h:3276
2 audio channels
Definition: ntv2enums.h:3669
static const ULWord gChannelToAudioInLastAddrRegNum[]
Definition: ntv2audio.cpp:31
#define DEC(__x__)
NTV2RegisterNumber
This selects audio channels 17 and 18.
Definition: ntv2enums.h:3141
NTV2FrameGeometry
Identifies a particular video frame geometry.
Definition: ntv2enums.h:348
This identifies the first Audio System.
Definition: ntv2enums.h:3897
The total number of audio systems on the device that can read/write audio buffer memory. Includes host audio system, if present. (New in SDK 17.0)
static const unsigned gAESChannelMappingShifts[4]
Definition: ntv2audio.cpp:1485
Declares numerous NTV2 utility functions.
#define NTV2_AUDIO_READBUFFEROFFSET_BIG
virtual bool SetHDMIOutAudioSource8Channel(const NTV2Audio8ChannelSelect inNewValue, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1, const NTV2Channel inWhichHDMIOut=NTV2_CHANNEL1)
Changes the HDMI output&#39;s 8-channel audio source.
Definition: ntv2audio.cpp:935
static const ULWord sAudioMixerInputSelectShifts[]
Definition: ntv2audio.cpp:546
virtual bool SetHDMIOutAudioFormat(const NTV2AudioFormat inNewValue, const NTV2Channel inWhichHDMIOut=NTV2_CHANNEL1)
Sets the HDMI output&#39;s audio format.
Definition: ntv2audio.cpp:1031
uint16_t UWord
Definition: ajatypes.h:221
virtual bool SetHeadphoneOutputGain(const ULWord inGainValue)
Sets the gain for the headphone out.
Definition: ntv2audio.cpp:705
virtual bool GetSuspendHostAudio(bool &outIsSuspended)
Answers as to whether or not the host OS audio services for the AJA device (e.g. CoreAudio on MacOS) ...
Definition: ntv2audio.cpp:1447
virtual bool GetEmbeddedAudioClock(NTV2EmbeddedAudioClock &outValue, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
For the given NTV2AudioSystem, answers with the current NTV2EmbeddedAudioClock setting.
Definition: ntv2audio.cpp:425
Obtain audio samples from the device microphone input, if available.
Definition: ntv2enums.h:2011
ULWord pcmControlMask
Definition: ntv2audio.cpp:56
virtual bool SetAudioMixerInputAudioSystem(const NTV2AudioMixerInput inMixerInput, const NTV2AudioSystem inAudioSystem)
Sets the Audio System that will drive the given input of the Audio Mixer.
Definition: ntv2audio.cpp:561
virtual bool SetAudioMixerInputGain(const NTV2AudioMixerInput inMixerInput, const NTV2AudioMixerChannel inChannel, const ULWord inGainValue)
Sets the gain for the given input of the Audio Mixer.
Definition: ntv2audio.cpp:618
virtual bool GetSDIOutputAudioEnabled(const NTV2Channel inSDIOutput, bool &outIsEnabled)
Answers with the current state of the audio output embedder for the given SDI output connector (speci...
Definition: ntv2audio.cpp:1623
#define NTV2_IS_VALID_AUDIO_SYSTEM(__x__)
Definition: ntv2enums.h:3914
bool GetTagsForFrameIndex(const UWord inIndex, NTV2StringSet &outTags) const
Answers with the list of tags for the given frame number.
Definition: ntv2card.cpp:744
#define NTV2_IS_VALID_AUDIO_SOURCE(_x_)
Definition: ntv2enums.h:2020
static const ULWord gAudioSystemToAudioControlRegNum[]
Definition: ntv2audio.cpp:45
NTV2AudioSystemSet::const_iterator NTV2AudioSystemSetConstIter
A handy const iterator into an NTV2AudioSystemSet. New in SDK 16.2.
virtual bool SetSDIOutputAudioEnabled(const NTV2Channel inSDIOutput, const bool &inEnable)
Enables or disables the audio output embedder for the given SDI output connector (specified as a chan...
Definition: ntv2audio.cpp:1640
virtual bool SetAudioInputDelay(const NTV2AudioSystem inAudioSystem, const ULWord inDelay)
Sets the audio input delay for the given Audio System on the device.
Definition: ntv2audio.cpp:1255
NTV2AudioSource
This enum value determines/states where an audio system will obtain its audio samples.
Definition: ntv2enums.h:2005
Declares the CNTV2Card class.
virtual bool GetInputAudioChannelPairsWithPCM(const NTV2Channel inSDIInputConnector, NTV2AudioChannelPairs &outChannelPairs)
For the given SDI input (specified as a channel number), returns the set of audio channel pairs that ...
Definition: ntv2audio.cpp:1559
#define NTV2_IS_WITHIN_AUDIO_CHANNELS_1_TO_16(__p__)
Definition: ntv2enums.h:3204
virtual bool GetEmbeddedAudioInput(NTV2EmbeddedAudioInput &outEmbeddedSource, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Answers with the device&#39;s current embedded (SDI) audio source for the given NTV2AudioSystem.
Definition: ntv2audio.cpp:377
virtual bool SetAudioMixerLevelsSampleCount(const ULWord inSampleCount)
Sets the Audio Mixer&#39;s sample count it uses for measuring audio levels.
Definition: ntv2audio.cpp:832
virtual bool SetAnalogAudioTransmitEnable(const NTV2Audio4ChannelSelect inChannelQuad, const bool inEnable)
Sets the specified bidirectional XLR audio connectors to collectively act as inputs or outputs...
Definition: ntv2audio.cpp:1677
ULWord NTV2DeviceGetFrameBufferSize(NTV2DeviceID id, NTV2FrameGeometry fg, NTV2FrameBufferFormat fbf)
virtual bool SetAudioPCMControl(const NTV2AudioSystem inAudioSystem, const bool inIsNonPCM)
Determines whether or not all outgoing audio channel pairs are to be flagged as non-PCM for the given...
Definition: ntv2audio.cpp:1287
Private include file for all ajabase sources.
The version number of the HDMI chipset on the device.
True if device audio systems can wait for VBI before starting. (New in SDK 17.0)
NTV2AudioRate
Definition: ntv2enums.h:1928
std::vector< uint32_t > ULWordSequence
An ordered sequence of ULWord (uint32_t) values.
virtual bool GetHeadphoneOutputGain(ULWord &outGainValue)
Answers with the current gain setting for the headphone out.
Definition: ntv2audio.cpp:697
std::string join(const std::vector< std::string > &parts, const std::string &delim)
Definition: common.cpp:468
NTV2AudioMixerChannel
Definition: ntv2enums.h:3225
#define NTV2_AUDIO_READBUFFEROFFSET
True if device has a firmware audio mixer.
virtual bool GetAudioMixerInputChannelsMute(const NTV2AudioMixerInput inMixerInput, NTV2AudioChannelsMuted16 &outMutes)
Answers with a std::bitset that indicates which input audio channels of the given Audio Mixer input a...
Definition: ntv2audio.cpp:734
Audio clock derived from the device reference.
Definition: ntv2enums.h:1992
8 audio channels
Definition: ntv2enums.h:3670
NTV2Audio4ChannelSelect
Identifies a contiguous, adjacent group of four audio channels.
Definition: ntv2enums.h:3271
virtual bool SetAudioOutputAESSyncModeBit(const NTV2AudioSystem inAudioSystem, const bool &inAESSyncModeBitSet)
Sets or clears the AES Sync Mode bit for the given Audio System&#39;s output.
Definition: ntv2audio.cpp:1761
True if device has a bi-directional analog audio connector.
static const ULWord gAudioSystemToSrcSelectRegNum[]
Definition: ntv2audio.cpp:28
True if device has a rotary encoder volume control.
virtual bool GetAudio20BitMode(const NTV2AudioSystem inAudioSystem, bool &outEnable)
Answers whether or not the device&#39;s NTV2AudioSystem is currently operating in 20-bit mode...
Definition: ntv2audio.cpp:1143
NTV2AudioChannelPairs::const_iterator NTV2AudioChannelPairsConstIter
Handy const iterator to iterate over a set of distinct NTV2AudioChannelPair values.
virtual bool GetAudioMixerInputGain(const NTV2AudioMixerInput inMixerInput, const NTV2AudioMixerChannel inChannel, ULWord &outGainValue)
Answers with the current gain setting for the Audio Mixer&#39;s given input.
Definition: ntv2audio.cpp:604
This selects audio channels 9 and 10 (Group 3 channels 1 and 2)
Definition: ntv2enums.h:3137
#define NTV2_IS_NORMAL_AUDIO_CHANNEL_QUAD(__p__)
Definition: ntv2enums.h:3312
virtual bool SetAESOutputSource(const NTV2Audio4ChannelSelect inAESAudioChannels, const NTV2AudioSystem inSrcAudioSystem, const NTV2Audio4ChannelSelect inSrcAudioChannels)
Changes the audio source for the given quad of AES audio output channels. By default, at power-up, for AJA devices that support AES audio output, the content of AES audio output channels 1/2/3/4 reflect what&#39;s being output from audio channels 1/2/3/4 from NTV2_AUDIOSYSTEM_1, likewise with audio channels 5/6/7/8, etc.
Definition: ntv2audio.cpp:1515
static const ULWord sAudioMixerInputSelectMasks[]
Definition: ntv2audio.cpp:545
virtual bool StopAudioOutput(const NTV2AudioSystem inAudioSystem)
Stops the playout side of the given NTV2AudioSystem, parking the "Read Head" at the start of the play...
Definition: ntv2audio.cpp:1117
NTV2EmbeddedAudioInput
This enum value determines/states which SDI video input will be used to supply audio samples to an au...
Definition: ntv2enums.h:1967
virtual bool SetNumberAudioChannels(const ULWord inNumChannels, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Sets the number of audio channels to be concurrently captured or played for a given Audio System on t...
Definition: ntv2audio.cpp:146
virtual bool StopAudioInput(const NTV2AudioSystem inAudioSystem)
Stops the capture side of the given NTV2AudioSystem, and resets the capture position (i...
Definition: ntv2audio.cpp:1207
#define NTV2_IS_VALID_AUDIO_CHANNEL_PAIR(__p__)
Definition: ntv2enums.h:3203
The number of SDI video inputs on the device.
static const ULWord gAudioDelayRegisterNumbers[]
Definition: ntv2audio.cpp:43
virtual bool SetSuspendHostAudio(const bool inSuspend)
Suspends or resumes host OS audio (e.g. CoreAudio on MacOS) for the AJA device.
Definition: ntv2audio.cpp:1441
Declares device capability functions.
virtual bool SetAudioMixerInputChannelsMute(const NTV2AudioMixerInput inMixerInput, const NTV2AudioChannelsMuted16 inMutes)
Mutes (or enables) the given output audio channel of the Audio Mixer.
Definition: ntv2audio.cpp:748
NTV2Audio8ChannelSelect
Identifies a contiguous, adjacent group of eight audio channels.
Definition: ntv2enums.h:3320
The size, in bytes, of the device&#39;s active RAM available for video and audio.
virtual bool GetAudioMixerInputAudioSystem(const NTV2AudioMixerInput inMixerInput, NTV2AudioSystem &outAudioSystem)
Answers with the Audio System that&#39;s currently driving the given input of the Audio Mixer...
Definition: ntv2audio.cpp:549
std::set< std::string > NTV2StringSet
Definition: ntv2utils.h:1158
NTV2EncodedAudioMode
Definition: ntv2enums.h:1940
True if device has any AES audio inputs or outputs.
static const ULWord sAudioMixerInputGainCh2Regs[]
Definition: ntv2audio.cpp:602
static NTV2RegisterNumber GetNonPCMDetectRegisterNumber(const NTV2Channel inSDIInputChannel, const bool inIsExtended=(0))
Definition: ntv2audio.cpp:1540
Audio clock derived from the video input.
Definition: ntv2enums.h:1993
virtual bool GetMultiLinkAudioMode(const NTV2AudioSystem inAudioSystem, bool &outEnabled)
Answers with the current multi-link audio mode for the given audio system.
Definition: ntv2audio.cpp:1712
virtual bool SetEmbeddedAudioClock(const NTV2EmbeddedAudioClock inValue, const NTV2AudioSystem inAudioSystem=NTV2_AUDIOSYSTEM_1)
Sets the NTV2EmbeddedAudioClock setting for the given NTV2AudioSystem.
Definition: ntv2audio.cpp:417
virtual bool SetAudioOutputPause(const NTV2AudioSystem inAudioSystem, const bool inPausePlayout)
Pauses or resumes output of audio samples and advancement of the audio buffer pointer ("play head") o...
Definition: ntv2audio.cpp:1151
The number of HDMI video inputs on the device.
static const PCM_CONTROL_INFO gAudioEngineChannelPairToFieldInformation[][8]
Definition: ntv2audio.cpp:61
virtual bool GetAudioMemoryOffset(const ULWord inOffsetBytes, ULWord &outAbsByteOffset, const NTV2AudioSystem inAudioSystem, const bool inCaptureBuffer=(0))
Answers with the byte offset in device SDRAM into the specified Audio System&#39;s audio buffer...
Definition: ntv2audio.cpp:1783
NTV2AudioMixerInput
Identifies the Audio Mixer&#39;s audio inputs.
Definition: ntv2enums.h:3254