Whilst adapting the code from the HiFiDuino project to work with my tri-Mono DACs I decided it would be a good idea to create a C++ class library that encapsulated I2C communication with the Sabre DAC and abstracted all the bits'n'bytes stuff so that it is far simpler to adapt to situations not catered for directly by the existing HiFiDuino code such as my 3 mono DAC configuration (quad-mono DACs would be another example that springs to mind).
I can make this library available if anyone is interested -
Here's some sample constructor code:
SabreDAC defaultDAC = SabreDAC(); // stereo mode, default settings
SabreDAC defaultDAC = SabreDAC(EightChannel); // 8 channel input mode, default settings (BIII only of course)
// tri-mono (right side) with TPA config
SabreDAC lowDAC = SabreDAC(MonoRight, AntiPhase, InPhase);
SabreDAC midDAC = SabreDAC(MonoRight, AntiPhase, InPhase);
SabreDAC hiDAC = SabreDAC(MonoRight, AntiPhase, InPhase, addrHiDAC); // 3rd DAC has I2C address remapping
Here are the functions currently available in the SabreDAC class:
void init(); // writes initial register values
boolean locked();
DACMode getMode();
byte getAddress(); // returns the I2C address
void mute();
void unmute();
void setAttenuation(byte attenuation);
void setAutoMuteLevel(byte level);
void setBypassOSF(boolean value);
void setDeEmphasis(DACDeEmphasis mode);
void setDPLLMode(DPLLMode mode);
void setDPLL(DPLLBandwidth bandwidth);
void setDPLL128Mode(DPLL128Mode mode);
void setFIRRollOff(FIR_RollOffMode mode);
void setFIRPhase(DACPhase phase);
void setIIRBandwidth(IIR_Bandwidth value);
void setInputMode(DACInputMode mode);
void setJitterReduction(boolean value);
void setJitterReductionBypass(boolean value);
void setQuantizer(DACQuantizer value);
void setNotchDelay(DACNotchDelay value);
void setPhaseB(DACPhase value);
void setSPDIFMode(SPDIFMode mode);
void setSPDIFAutoDeEmphasis(boolean value);
and enumerators:
enum DACInputMode{SPDIF, I2SorDSD};
enum DACDeEmphasis{DeEmph32k, DeEmph441k, DeEmph48k};
enum DACMode{MonoLeft, MonoRight, Stereo, EightChannel};
enum DACNotchDelay{NoDelay=0, Delay4=1, Delay8=2, Delay16=3, Delay32=4, Delay64=5};
enum DACPhase{InPhase, AntiPhase};
enum DACQuantizer{sixBit=0, sevenBit=1, eightBit=2, nineBit=3};
enum DPLLBandwidth{None=0, Lowest=1, Low=2, MediumLow=3, Medium=4, MedHigh=5, High=6};
enum DPLLMode{AllowAll, UseBest};
enum DPLL128Mode{UseDPLLSetting, MultiplyBy128};
enum FIR_RollOffMode{Slow, Fast};
enum FIR_Coefficients{FIR27, FIR28};
enum IIR_Bandwidth{IIR_Normal, IIR_50k, IIR_60k, IIR_70k};
enum SPDIFMode{SPDIF_Auto, SPDIF_Manual};