Go Back   Home > Forums > > >
Home Forums Rules Articles diyAudio Store Blogs Gallery Wiki Register Donations FAQ Calendar Search Today's Posts Mark Forums Read

Twisted Pear Superior quality electronic kits

Reply
 
Thread Tools Search this Thread
Old 8th January 2019, 06:35 AM   #91
francolargo is offline francolargo  United States
diyAudio Member
 
Join Date: Mar 2007
Location: Twin Cities, MN
Oh! I've been making changes to the GitHub version and maybe you don't have this line after the import statements...

bus = smbus.SMBus(1)

if not, add it there...
  Reply With Quote
Old 8th January 2019, 07:01 AM   #92
twluke is offline twluke  Japan
diyAudio Member
 
Join Date: Nov 2012
Location: Tokyo
Control of BBB-based audio appliances
[QUOTE=twluke;5657511]Thanks for this info but, sorry to say, it didn't work.
Code:
root@arm:~# python ./DACserver.py
Traceback (most recent call last):
  File "./DACserver.py", line 31, in <module>
    dacregister()
  File "./DACserver.py", line 16, in dacregister
    bus.write_byte_data(0x48, 0x07, mute)  # mute
 NameError: global name 'bus' is not defined
Well I modified part of the script like below:

Code:
 
import smbus
 bus = smbus.SMBus(1)
import os
mutebus = 0x61  # default mute setting
FIR = 0x60  # unmute plus default filter shape
# The following routines run once to initialize the DAC
# setup I2C volume, DPLL bandwidth, other es9028 parameters
def dacregister(): # enter desired register values for initialization - these are mine
   bus.write_byte_data(0x48, 0x07, 0x61)  # mute
Execution of this command returned successful answer:
Code:
root@arm:~# python ./DACserver.py
DAC ready
This is my current status. Will continue. After sending this, I got the same answer from you. Thank you!

Last edited by twluke; 8th January 2019 at 07:03 AM.
  Reply With Quote
Old 8th January 2019, 07:16 AM   #93
francolargo is offline francolargo  United States
diyAudio Member
 
Join Date: Mar 2007
Location: Twin Cities, MN
Good - you can now confirm that your registers are correct using i2cget.

I'm definitely making progress here but must quit for now. However, the touchscreen slider interface that i'm using for volume control is difficult to 'hack' without the 'NetIO' interface from my iOS devices. One question is whether you would like to have such a mobile interface for your system? If not, then a 'louder' and 'softer' routine can be written and accessed using netcat. The touchscreen sliders, though, are nice! If you are curious, below is a shot of my iPad controller screen that runs using NetIO. So if you wanted such a controller, I can leave the NetIO code intact. Again, all of the switching and routing and I2C is managed by the python program, which can execute system commands and kill processes as needed from within the script.

Information on NetIO is HERE. Documentation is not great but I have solved most of the issues by trial-and-error.
Attached Images
File Type: jpg Image-1.jpg (239.5 KB, 64 views)
  Reply With Quote
Old 9th January 2019, 10:36 PM   #94
francolargo is offline francolargo  United States
diyAudio Member
 
Join Date: Mar 2007
Location: Twin Cities, MN
OK twluke - I hope your objectives will be met by the updated python program named DACserver.py that I placed on the GitHub page we have been using.

This program initializes your 9028/9038 DAC according to the register settings we have discussed. Then it continues to run and allows you to change certain registers. The code is most certainly NOT optimized because it is derived from a much more complicated program. For example, there are definitions with only one line. Also, the asyncore server and client are more complex than necessary. But importantly, they work on my system. I can't run sound with your settings, but I've confirmed all of the register manipulations. These manipulations are defined in the section: 'def handle_command'. The syntax of these brief commands is simple and you will have no trouble adding or deleting to suit your needs. To access these commands you need only open a second ssh socket and then use netcat to send text to the program. Example:

Code:
echo 'set volume 110' | nc -q .1 10.0.1.5 8193
in the above example, 10.0.1.5 is the IP of my BBB, and 8193 is the port I selected from the range 8192-8195. Best if each TCP source uses a different port. After running the echo command, the volume register should be at 0x6e:

Code:
root@beaglebone:/usr/script# echo 'set volume 110' | nc -q .1 10.0.1.5 8193
root@beaglebone:/usr/script# i2cget -y 1 0x48 0x1b
0x6e
Here are the commands to which DACserver.py will respond:

'set volume XXX' - where XXX is from 0-127 (0 is very quiet but not mute; 127 is no attenuation)
'+' - increases volume by 10dB
'-' - decreases volume by 10dB
'freq' - reports the frequency of PCM
'apodize' - sets register 7 to apodizing, fast roll-off, linear phase filter with IIR @ 50K (0x82)
'slow-min' - sets register 7 to slow roll-off, minimum phase filter (0x62)
'fast-min' - sets register 7 to fast roll-off, minimum phase filter (0x42)
'slow-linear' - sets register 7 to slow roll-off, linear phase filter (0x22)
'fast-linear' - sets register 7 to fast roll-off, linear phase filter (0x02)
'brick' - sets register 7 to brick wall filter (0xe2)

Again, all register 7 settings use the 50k IIR setting. Of course one could modify IIR independently using an additional variable to remember the desired FIR filter.

You will see that there is a 'def police()' line followed by various commands. This is something that you may not need, but I suggest that you use it at least at first. This routine checks that the DAC is in stereo mode, and if for any reason it has been knocked out of stereo mode it will restore ALL of the initialization register settings. This is done every 0.3 seconds. For systems that use balanced amps, this can help prevent accidents. There may be a better register to monitor than number 15, and that can be easily changed. For my system, I monitor register 15. The 'police()' function also can catch any disruption in I2C serial communication. That is usually not the worst thing in the world, but requires a cold re-boot. However, I automatically kill whatever source program is running on the BBB, so that when the DAC comes back online after re-boot it doesn't get any input until all registers are ready. Those lines are commented-out, but are there for your modification if you wish.

Finally, even for non-programmers like myself, Python is easy enough to work in so that the BBB's GPIO and command-line functions can be manipulated, and 'handle commands' can be customized for different uses. I gave you an (inactive) example of how you can select the output of a player - I used Squeezelite - in order to secondarily manipulate the PCM in ALSA. ALSA LADSPA filters can create a crossover, an EQ, etc. by placement in unique pathways between the rendering program and the output pins. So I have made specialized ALSA pathways using custom plugs for each mode of system operation, and can switch among them using simple commands like 'os.system(command-line function)'. [hint: sometimes os.system commands are a bit slow and need to be followed by a brief sleep command.]

I hope it will be easy for you to refine and customize the 'handle commands'. Any questions or comments, please let me know! And if you decide to use NetIO with a mobile device as a controller (Android or iOS), I can help you there too... Another possibility might be something like an SSH tunnel from your mac, but I have no experience with that. Perhaps keyboard macros incorporating SSH to the BBB could simplify things.

Cheers,

Frank
  Reply With Quote
Old 9th January 2019, 11:32 PM   #95
francolargo is offline francolargo  United States
diyAudio Member
 
Join Date: Mar 2007
Location: Twin Cities, MN
One more thing:

Please be VERY CAREFUL introducing this software to your system! Remember, your settings won't work for me so they haven't been verified. First, test all register manipulations with the amps off. Then, if you have analog volume control, test digital volume controls, the police function, etc. with analog volume limiting output. To test the 'police()' routine, simply use 'i2cset to change register 0x0f. Good luck!

F.

Last edited by francolargo; 9th January 2019 at 11:35 PM.
  Reply With Quote
Old 10th January 2019, 02:53 PM   #96
twluke is offline twluke  Japan
diyAudio Member
 
Join Date: Nov 2012
Location: Tokyo
Control of BBB-based audio appliances
Quote:
Originally Posted by francolargo View Post
OK twluke - I hope your objectives will be met by the updated python program named DACserver.py that I placed on the GitHub page we have been using.
-snip-

Cheers,

Frank
Hi Frank, thank you for this updated script. It worked well without any glitch!, though only tried volume control. This weekend, I'll get more insight into this script.

Appreciated your courtesy in depth, thank you very much.
  Reply With Quote
Old 10th January 2019, 02:59 PM   #97
francolargo is offline francolargo  United States
diyAudio Member
 
Join Date: Mar 2007
Location: Twin Cities, MN
Excellent! By the way, the netcat command I gave has sometimes caused errors. If that happens, try removing the -q .1 flag (a 0.1 second delay). like...
Code:
echo 'set volume 110' | nc 10.0.1.5 8193
  Reply With Quote

Reply


Control of BBB-based audio appliancesHide this!Advertise here!
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding a volume control to a TPA3122-based audio kit i336 Class D 2 9th June 2015 07:50 AM
How do I use my appliances on a Furman PL8CE? Akins Equipment & Tools 21 20th May 2015 06:24 PM
Powering non-speaker appliances with an amp cspirou Everything Else 4 4th November 2014 11:34 AM
Household Appliances repair forum Tarzan Everything Else 7 22nd August 2012 08:54 PM
Transformer-based volume control wboyd Analogue Source 4 18th August 2004 05:57 PM


New To Site? Need Help?

All times are GMT. The time now is 11:34 PM.


Search Engine Optimisation provided by DragonByte SEO (Pro) - vBulletin Mods & Addons Copyright © 2019 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 14.29%
vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2019 DragonByte Technologies Ltd.
Copyright ©1999-2019 diyAudio
Wiki