Home > Arduino, Code > New Version of Code: v 1.1a

New Version of Code: v 1.1a

November 11, 2012 Leave a comment Go to comments


Finished a small update to improve the display of input format and sample rate. Also, the Apple remote code now supports all remotes without code change. This is how it looks like when displaying different input formats and sample rates.

The sample rate and input mode (PCM, DSD or SPDIF) are reported by the Sabre32 DAC in the status register, so what you see is always the truth. As you evaluate different interfaces you will immediately know if what you expect is what you are getting, such as for example, whether there is sample rate conversion and whether DSD is converted to PCM.

I decided to show the nominal sample rate rather than the exact sample rate as calculated by the DPLL. The actual sample frequency varies from adapter to adapter but it is typically within a few hertz. For example 44 KHz will measure at 44099 Hz or 44101 Hz.

The code continues to calculate the exact value of the sample rate and is available in case anyone wishes to make use if it. For example, the older models of the Musiland interfaces had a “fast” and “exact” mode in generating the sample rate. In “fast” mode, the sample rate deviated from the standard value “quite a bit” (but still within the specified tolerances) so it was interesting to see the actual sample rate, which in this case was 44121 Hz for the 44100 Hz standard.


In addition, I’ve added selection of I2S format: 32 bit (“I32″), 24 bit (I24”), etc;  left justified and right justified formats as specified in the data sheet. These settings are only shown when you enter “select” mode as shown below.


Thanks to a tip by a reader, the command byte in the Apple remote protocol is only 7-bit rather than the full 8-bit. By making this adjustment (only one line of code required), the code is now compatible with ALL remote controls manufactured by Apple, including the white plastic model. For more information, check the Apple Remote tab: [link]


Same code configuration as before:

In order to support your device and configuration look for this section in the code and make the changes as instructed in the code:

/******************* Code Customization Section *********************/

/* First: Choose the clock frequency you have and comment the other */

#define USE80MHZ  
//#define USE100MHZ

/* Second: Choose your configuration

   | CONFIGURATION       | #define DUALMONO | #define TPAPHASE |
   | Dual mono in-phase  | un-comment       | comment          |
   | Dual mono TPA phase | un-comment       | un-comment       |
   | Stereo              | comment          | comment          |
   |---------------------|------------------|------------------|    */

#define DUALMONO
#define TPAPHASE

/* Optionally choose the number of inputs. 6 is the max without 
   modifying the code. You could lower the number of input choices
   here                                                             */

#define ICHO 6

/* Optionally change the name of the inputs. Keep 6 characters
   Use blanks if necessary                                          */

char no0[] = "PC-BST";
char no1[] = "APPLtv";
char no2[] = "SPDIF1";
char no3[] = "DENON ";
char no4[] = "SACD-1";
char no5[] = "AMNERO";

/* Make sure you use the correct chip address for each board

   for stereo Buffalo: use address 0x90
   for dual mono: Use address 0x90 for mono left Buffalo 
                  Use address 0x92 for mono right Buffalo           */


The code above is configured as 80 MHz, DUALMONO TPAPHASE


You can download the latest code from the CODE tab: [link]

  1. David Quayle
    November 11, 2012 at 09:22

    Whats wrong with the Apple Remote code?

    I have always wondered why you dont use the remote for all of the functions & do away with the rotary encoder?

    • BlogGeanDo
      November 12, 2012 at 02:56

      Just what Corpius said. There are a few reasons why I didn’t use the remote for everything:
      – I coded the rotary encoder first before I added the remote. I think when you can reach the controller, a rotary encoder is a “more natural” interface.
      – When far from the controller, I can’t even see the settings, so (for me) using the remote to change the setting is not useful
      – I wanted to reserve some of the buttons of the remote to control the player application. With Leonardo, you could program some of the buttons to select a next song, etc.

  2. November 11, 2012 at 22:52

    David Quayle :
    Whats wrong with the Apple Remote code?
    I have always wondered why you dont use the remote for all of the functions & do away with the rotary encoder?

    In my version of the code I have already the corrected remote code. The original code works for most remotes, but when the code is changed to get just the first 7 bits of the 3th byte it can be used for any Apply remote. https://hifiduino.wordpress.com/apple-aluminum-remote/

    @glt. I also got a message about the incorrect displayed sample rate value from somebody for who I changed some of the code. He also noticed that it displays 44.1kHz when playing at (most probably) 5.6mHz. Unfortunately I have no way of confirming or testing this because I have no device that outputs DSD audio formats. Are you multiplying the retrieved sample rate by 64 to get the correct value or is there another way of retrieving the correct value directly from the chip?

    • BlogGeanDo
      November 12, 2012 at 02:49

      Yeah, just multiply by 64 to get the DSD frequency. You could simplify the calculation by just doing the floating point operation as specified in the datasheet. The way I did it was to avoid floating point and to increase the accuracy of the integer operation. (floating point operation is “much slower” than integer operations)

  3. Rich
    November 12, 2012 at 07:46

    Thanks for the SR code update! It was just what I needed! Thanks for making the code available to folks like me who couldn’t code to save my soul…lol


    • Rich
      November 12, 2012 at 07:53

      I am the one Corpius is referring to. He has helped me so much!
      DSD was displaying 44.1. Now it reads 2.8MHz (exporting from modded Denon 3910).

    • BlogGeanDo
      November 12, 2012 at 17:51

      Hi Rich, you are welcome. It is good to share the fun one is having with other people :-). I also have a Denon (2910) that I want to tap the DSD signal but have yet to touch it. I do find that series of Denon player the “United Nations” of the disc players as they can play “all” formats, even the dueling SACD and DVD-A formats… Glad to hear that the SR is working correctly with the Denon. Seems standard output from the SACD decoder is 2.8 MHz. Try the 5.6 MHz files available from Design W Sound…

      • Rich
        November 12, 2012 at 19:37

        Hi glt. The 2910 was a first choice but I picked up a 3910 for cheap. The 3910 was harder for me to figure out as there are multiple DAC chips in dual differential mode. Like, which one or does it matter? Today it reads 6.1MHz playing SACD so I don’t know what to believe. It looks a lot better than displaying 44.1 though. 😉 I just bought an enclosure/w front panel work from modushop and haven’t got a hi-res USB or DSD via USB input yet. I may wait for the newer version of the Amanero with DSD capability. IIRC he is adding that. The DSD via Denon is very sensitive (momentary dropouts) to a light being turned on in the room or a powered recliner chair activated even though it is on a dedicated circuit. I don’t have many SACD but would like to figure that out.

      • BlogGeanDo
        November 13, 2012 at 00:40

        The Amanero already has DSD capability. Regarding the 6.1MHz, that sounds like a bug in the code. If you could pay attention, see if the frequency is consistent for the same disc and if 6.1 MHz is particular to a specific disc. Thanks…

  4. November 12, 2012 at 20:26

    What are the benefits of the possibility to switch between the I2S input formats? Why would one want to scale it down to fi 24 bits or even lower? Perhaps you have a good reason to allow users to have these options?

    • BlogGeanDo
      November 13, 2012 at 00:43

      There is no really good reason except for some “odd” device that works RJ or LJ. The bit-depth would have been useful if it supported 24 or 16 bit frames. But the way it is right now, the DAC only supports 64 bit frames, so if you reduce the bit-depth, it would probably just ignore the least significant bits.

      I was implementing this when trying to figure out why 352K did not work on an 80MHz clock, and since I had implemented it, I thought it could be useful for someone…

  5. Rich
    November 13, 2012 at 02:08

    BlogGeanDo :The Amanero already has DSD capability. …

    Sorry, my bad….following too many USB threads.

  6. David Quayle
    November 14, 2012 at 10:03

    I hope your code works with the new BIIIse

  7. November 14, 2012 at 10:19

    David Quayle :
    I hope your code works with the new BIIIse

    Hi David,
    The code should work fine for the BIIIse, except for the spdif input selection. You’ll need to add this yourself. Here is some example code for the input selection: http://ce-designs.net/index.php/manuals/7-buffalo3-arduino-input-selection

    • BlogGeanDo
      November 14, 2012 at 15:12


      Nice code!.

  8. Rich
    November 14, 2012 at 19:06

    BlogGeanDo :
    Regarding the 6.1MHz, that sounds like a bug in the code. If you could pay attention, see if the frequency is consistent for the same disc and if 6.1 MHz is particular to a specific disc. Thanks…

    I experimented with playing DSD today. My modded Denon exports DSD/PCM via a TP Teleporter. A TP Otto II controlled with a manual switch chooses which signal to export to the DAC. I tried two different SACD’s. Both read 2.8MHz when playing. When ejected, the SR shows 6.1MHz. It drops to 2.8 when either SACD is replayed. It didn’t read 6.1MHz at all when playing today.

    I do get these momentary interrupts when playing SACD’s with the Denon (a light turned on in the room, a reclining chair in same room activated) despite my two channel being on a separate dedicated circuit, and wonder if that can skew the signal and cause it to read wrong. They two circuits are on the same bus in breaker panel. That is on my list to eventually solve.


    • BlgGear
      November 14, 2012 at 20:21

      Hi Rich,

      Thank you so much for doing the experiments and reporting. It seems that when you eject, the DAC still locks into some “idle” frequency. I am surprised it is not 2.8 MHz. Right now I am just comparing the actual frequency to a close value and displaying the nominal value. I think it is a good idea to narrow the comparison value to be close to the actual frequency and display some other message if the frequency is substantially different from the expected value. Regarding the hiccups, you can try increasing the DPLL. I also doubt it can change the frequency of the clock.

      • Rich
        November 14, 2012 at 21:23

        You are most welcome. 😉 Just to add it also reads 44MHz after a CD is ejected so the locking onto some idle frequency idea sounds logical. I must have fat fingered the code somewhere…the oversample icon appears when first powered up, but disappears after any menu selection is made. The music still plays so no big deal. It takes a special person to do code, and I ain’t it….lol High marks to you.

  9. David Quayle
    November 14, 2012 at 21:18

    Thanks, muchly, the SE wont come with any instructions, I’m dangerous with instructions let alone without, so I may never get as far as the code 🙂

  10. November 14, 2012 at 21:29

    Narrowing the comparison value down to be close to the frequency sounds like a good and simple solution for the problem.

  11. September 14, 2016 at 15:25

    o meblach szkolnych

  12. September 14, 2016 at 17:44

    videos incesto real

  13. September 14, 2016 at 19:06

    DC locksmith

  14. September 17, 2016 at 08:06

    Wow! This can be one particular of the most helpful blogs We have ever arrive across on this subject. Actually Excellent. I’m also an expert in this topic therefore I can understand your effort.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s