01-17-2021, 06:14 PM
Hi guys,
Since last thread is closed and no solution was provided - I decided to spent couple of hours integrating brand new DAC from HiFiBerry into Moode. Later maybe someone will add it to source code or later I will try contribute this changes to project itself.
It is working with current latest version - 7.01, but i think it will be also working with older versions as well. Source code lines numbers are related to current version 7.01 - but even you're working with older version you wont have any problem with finding them in code
So, in order to make it work you need to:
1. Add new driver to moode
Just like TookAFace suggested here but remove chip options (I'm not quite sure if there is a difference with or without these options. Since this is PCM1796 - I haven't seen any additional configuration needed like it was with PCM5122 (older boards like DAC+ PRO))
2. Now we need to edit playerlib.php file and add custom name for volume control and modify driver count
Open editor with code:
Volume control:
Drivers count (originally 78 - now 79):
3. Generate new checksums
After making changes we need to generate new checksum for both playerlib file and driver list. In moode there is table called cfg_hash with calculated values. After changes both checksums are no longer valid - so moode will break.
Well, we might bypass this integrity check and save some time, but let's play with moode nicely;-)
Generate new checksum for playerlib:
Store output - will be needed in a minute ;-) Should be md5 sum - something like: d717dc9bc46782b962467a57de3fcedb
Generate new checksum for device list:
Create a file with devices in same way like moode does and store it in temporary folder:
Now we can easily calculate checksum from file:
Store output
4. Modify checksums ind DB
There is a trigger in db which blocks any operation on cfg_hash table so we gonna remove it, modify table and recreate trigger (if you skip last part (recreation of trigger) then integrity check will fail in schema check).
4.1 Remove trigger:
4.2 Modify checksums in db
Change PASTE_GENERATED_OUTPUT_HERE to your generated checksum for playerlib.php:
Change PASTE_GENERATED_OUTPUT_HERE to your generated checksum for devices list:
4.3 Recreate a trigger
5. Reboot raspberry
Now - just select new driver in Audio Options and enjoy music;-)
Since last thread is closed and no solution was provided - I decided to spent couple of hours integrating brand new DAC from HiFiBerry into Moode. Later maybe someone will add it to source code or later I will try contribute this changes to project itself.
It is working with current latest version - 7.01, but i think it will be also working with older versions as well. Source code lines numbers are related to current version 7.01 - but even you're working with older version you wont have any problem with finding them in code
So, in order to make it work you need to:
1. Add new driver to moode
Just like TookAFace suggested here but remove chip options (I'm not quite sure if there is a difference with or without these options. Since this is PCM1796 - I haven't seen any additional configuration needed like it was with PCM5122 (older boards like DAC+ PRO))
Code:
sudo sqlite3 /var/local/www/db/moode-sqlite3.db " INSERT INTO cfg_audiodev (id, name, dacchip, chipoptions, iface, list, driver, drvoptions) VALUES (75, 'HiFiBerry DAC2 HD', 'Burr Brown PCM1796', '', 'I2S', 'yes', 'hifiberry-dacplushd', '');"
2. Now we need to edit playerlib.php file and add custom name for volume control and modify driver count
Open editor with code:
Code:
sudo nano /var/www/inc/playerlib.php
Volume control:
Code:
Line:2071
elseif ($i2sdevice == 'HiFiBerry DAC+ DSP') {
$mixername = 'DSPVolume';
}
elseif ($i2sdevice == 'HiFiBerry DAC2 HD') {
$mixername = 'DAC';
}
Drivers count (originally 78 - now 79):
Code:
Line:270
// Verify the row count
$count = sysCmd('sqlite3 ' . SQLDB_PATH . " \"SELECT COUNT() FROM cfg_audiodev\"");
if ($count[0] != 79) {
$_SESSION['ic_return_code'] = '4';
return false;
}
3. Generate new checksums
After making changes we need to generate new checksum for both playerlib file and driver list. In moode there is table called cfg_hash with calculated values. After changes both checksums are no longer valid - so moode will break.
Well, we might bypass this integrity check and save some time, but let's play with moode nicely;-)
Generate new checksum for playerlib:
Code:
php -r 'echo md5(file_get_contents("/var/www/inc/playerlib.php"));'
Store output - will be needed in a minute ;-) Should be md5 sum - something like: d717dc9bc46782b962467a57de3fcedb
Generate new checksum for device list:
Create a file with devices in same way like moode does and store it in temporary folder:
Code:
sudo sqlite3 /var/local/www/db/moode-sqlite3.db "SELECT * FROM cfg_audiodev WHERE drvoptions NOT IN ('slave', 'glb_mclk') AND chipoptions = ''" > /tmp/moode-devices.txt
Code:
php -r 'echo md5(file_get_contents("/tmp/moode-devices.txt"));'
Store output
4. Modify checksums ind DB
There is a trigger in db which blocks any operation on cfg_hash table so we gonna remove it, modify table and recreate trigger (if you skip last part (recreation of trigger) then integrity check will fail in schema check).
4.1 Remove trigger:
Code:
sudo sqlite3 /var/local/www/db/moode-sqlite3.db "DROP TRIGGER ro_columns"
4.2 Modify checksums in db
Change PASTE_GENERATED_OUTPUT_HERE to your generated checksum for playerlib.php:
Code:
sudo sqlite3 /var/local/www/db/moode-sqlite3.db "UPDATE cfg_hash SET value='PASTE_GENERATED_OUTPUT_HERE' WHERE id=10"
Change PASTE_GENERATED_OUTPUT_HERE to your generated checksum for devices list:
Code:
sudo sqlite3 /var/local/www/db/moode-sqlite3.db "UPDATE cfg_hash SET value='PASTE_GENERATED_OUTPUT_HERE' WHERE id=8"
4.3 Recreate a trigger
Code:
sudo sqlite3 /var/local/www/db/moode-sqlite3.db "CREATE TRIGGER ro_columns BEFORE UPDATE OF param, value, [action] ON cfg_hash FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'read only'); END"
5. Reboot raspberry
Code:
sudo reboot
Now - just select new driver in Audio Options and enjoy music;-)