Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Login


Options
View
Go to last post Go to first unread
Possum  
#1 Posted : Saturday, November 12, 2016 10:01:25 PM(UTC)
Possum

Rank: Member

Groups: Member
Joined: 8/5/2012(UTC)
Posts: 208
Australia

Thanks: 4 times
Was thanked: 16 time(s) in 14 post(s)
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};
Possum  
#2 Posted : Saturday, November 19, 2016 1:46:41 AM(UTC)
Possum

Rank: Member

Groups: Member
Joined: 8/5/2012(UTC)
Posts: 208
Australia

Thanks: 4 times
Was thanked: 16 time(s) in 14 post(s)
Surprised there are no takers - everyone must be hardcore C and Hexadecimal programmers out there in Buffalo Arduino land :-)
Russ White  
#3 Posted : Sunday, November 27, 2016 2:50:08 AM(UTC)
Russ White

Rank: Administration

Groups: Administration, Customer
Joined: 10/24/2006(UTC)
Posts: 3,979
Location: Nashville, TN

Thanks: 25 times
Was thanked: 89 time(s) in 83 post(s)
Just put it up on github :)
Possum  
#4 Posted : Saturday, December 10, 2016 12:05:44 AM(UTC)
Possum

Rank: Member

Groups: Member
Joined: 8/5/2012(UTC)
Posts: 208
Australia

Thanks: 4 times
Was thanked: 16 time(s) in 14 post(s)
Brian Donegan  
#5 Posted : Saturday, December 10, 2016 12:46:50 AM(UTC)
Brian Donegan

Rank: Administration

Groups: Administration, Customer
Joined: 10/24/2006(UTC)
Posts: 2,868
Location: Massachusetts, USA

Thanks: 2 times
Was thanked: 141 time(s) in 134 post(s)
Originally Posted by: Possum Go to Quoted Post


Nice comments. Good work.
Russ White  
#6 Posted : Monday, December 12, 2016 11:16:03 PM(UTC)
Russ White

Rank: Administration

Groups: Administration, Customer
Joined: 10/24/2006(UTC)
Posts: 3,979
Location: Nashville, TN

Thanks: 25 times
Was thanked: 89 time(s) in 83 post(s)
Nice work!
Possum  
#7 Posted : Thursday, December 15, 2016 11:43:52 AM(UTC)
Possum

Rank: Member

Groups: Member
Joined: 8/5/2012(UTC)
Posts: 208
Australia

Thanks: 4 times
Was thanked: 16 time(s) in 14 post(s)
Thanks for the complements Brian and Russ. Happy to contribute something to the cause :-). Am also an IT pro and this is the first bit of coding I have done for years so wanted to make a good job of it.

I have been using the ESP8266 WiFi shield - which is also conveniently a 3.3V unit for I2C connection to the DAC

My next code publication may well be an IoT WiFi API control library and Buffalo App for Android - dependent upon coding time over the Christmas break :-)

Edited by user Thursday, December 15, 2016 11:44:55 AM(UTC)  | Reason: Not specified

Russ White  
#8 Posted : Thursday, December 15, 2016 1:35:01 PM(UTC)
Russ White

Rank: Administration

Groups: Administration, Customer
Joined: 10/24/2006(UTC)
Posts: 3,979
Location: Nashville, TN

Thanks: 25 times
Was thanked: 89 time(s) in 83 post(s)
I am looking forward to seeing what you do! :) Have fun! Thank you for the contribution to the community.
Rss Feed  Atom Feed
Users browsing this topic
GuestUser (5)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.