Skip to content

Commit

Permalink
Merge pull request #129 from bang-olufsen/development
Browse files Browse the repository at this point in the history
Jul-Dec 2020 Updates
  • Loading branch information
tuomashamalainen committed Jan 3, 2021
2 parents 14166f7 + ebaef93 commit 7324b7c
Show file tree
Hide file tree
Showing 133 changed files with 17,343 additions and 3,145 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,7 @@ typings/
/Beocreate2/beo-settings/*

# Distribution files for Beocreate Connect
/BeocreateConnect/dist/*
/BeocreateConnect/dist/*

# Playground
/Beocreate2/beo-playground/
41 changes: 36 additions & 5 deletions Beocreate2/beo-extensions/alsa-ttable/alsa-ttable-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ alsa_ttable = (function() {

settings = {
role: "stereo",
limit_db: 0
limit_db: 0,
min_slider: 0
}

$(document).on("alsa-ttable", function(event, data) {
Expand All @@ -14,10 +15,16 @@ $(document).on("alsa-ttable", function(event, data) {
settings = data.content.settings;

if (settings.limit_db) {
$(".alsa-volume-limit-slider span").attr("data-content", alsaVolumeLimitPercentageToSliderText(settings.limit_db))
$(".alsa-volume-limit-slider span").attr("data-content", alsaVolumedBToSliderText(settings.limit_db))
$(".alsa-volume-limit-slider").slider("value", settings.limit_db);
}

if (settings.min_slider) {
console.log(settings.min_slider)
$(".alsa-volume-min-slider span").attr("data-content", alsaVolumePercentToSliderText(settings.min_slider))
$(".alsa-volume-min-slider").slider("value", settings.min_slider);
}

if (settings.role == "mono") {
document.getElementById("ttable-alsa-mono").classList.add("selected");
document.getElementById("ttable-alsa-stereo").classList.remove("selected");
Expand All @@ -37,17 +44,36 @@ $(".alsa-volume-limit-slider").slider({
value: 0,
slide: function( event, ui ) {
settings.limit_db = ui.value
$(".alsa-volume-limit-slider span").attr("data-content", alsaVolumeLimitPercentageToSliderText(ui.value));
$(".alsa-volume-limit-slider span").attr("data-content", alsaVolumedBToSliderText(ui.value));

}
});

$(".alsa-volume-min-slider").slider({
range: "min",
min: 0,
max: 70,
value: 0,
slide: function( event, ui ) {
settings.min_slider = ui.value
console.log("min slider1: "+ui.value);
$(".alsa-volume-min-slider span").attr("data-content", alsaVolumePercentToSliderText(ui.value));
console.log("min slider2: "+ui.value);
update_volrange(ui.value);

}
});

function alsaVolumeLimitPercentageToSliderText(value) {
function alsaVolumedBToSliderText(value) {
sliderText = value+" dB";
return sliderText;
}

function alsaVolumePercentToSliderText(value) {
sliderText = value+"%";
return sliderText;
}

function selectRole(role) {
console.log("Selecting role "+role)
if (role == "mono") {
Expand All @@ -61,11 +87,16 @@ function selectRole(role) {
}

function save() {
console.log("ttable save")
console.log("settings: "+settings.role+"/"+settings.limit_db);
beo.send({target: "alsa-ttable", header: "saveSettings", content: {settings}});
}

function update_volrange(min) {
console.log("updating volrange");
settings.min_slider = min;
beo.send({target: "alsa-ttable", header: "setVolRange", content: {settings}});
}

return {
selectRole: selectRole,
save: save
Expand Down
25 changes: 24 additions & 1 deletion Beocreate2/beo-extensions/alsa-ttable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var debug = beo.debug;

var defaultSettings = {
"limit_db": -3,
"min_slider": 0,
"role": "mono"
};

Expand All @@ -44,6 +45,13 @@ function read_settings() {
console.error("Could not read ALSA-ttable settings via speaker-role.")
}

if (beo.extensions["sound"] &&
beo.extensions["sound"].getVolumeControlRange != undefined) {
settings.min_slider = beo.extensions["sound"].getVolumeControlRange()[0];
} else {
settings.min_slider = 0
}

beo.sendToUI("alsa-ttable", {header: "ttableSettings", content: {settings: settings}});
} catch (error) {
console.error("Exception reading settings via speaker-role:", error);
Expand All @@ -53,12 +61,17 @@ function read_settings() {

function write_settings(settings) {
var child;

console.error("Write ttable settings");

try {
child = execSync('/opt/hifiberry/bin/speaker-role '+settings.role + " "+settings.limit_db)
child = execSync('/opt/hifiberry/bin/speaker-role '+settings.role + " "+settings.limit_db, timeout=10000)
} catch (error) {
console.error("Exception calling speaker-role:", error);
}



}

beo.bus.on('general', function(event) {
Expand Down Expand Up @@ -86,6 +99,16 @@ beo.bus.on('alsa-ttable', function(event) {
}
}

if (event.header == "setVolRange") {
if (beo.extensions["sound"] &&
beo.extensions["sound"].setVolumeControlRange != undefined) {
settings = event.content.settings
beo.extensions["sound"].setVolumeControlRange(min = settings.min_slider, max = 100);
} else {
console.error("sound.setVolumeControlRange not available")
}
}

});


Expand Down
12 changes: 12 additions & 0 deletions Beocreate2/beo-extensions/alsa-ttable/menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,20 @@ <h2>Volume limit</h2>
</div>
<p data-translation="limitVolumeNotice">Limit the maximum volume level of sources.</p>

<h2>Volume slider minimum</h2>
<div id="alsa-ttable-minvolume-wrap">
<!-- <h2 data-translation="sliderMinVolume"></h2> -->
<div class="slider-wrap">
<div class="symbol" style="-webkit-mask-image: url(common/symbols-black/volume-quiet.svg); mask-image: url(common/symbols-black/volume-quiet.svg);"></div>
<div class="alsa-volume-min-slider black show-value"></div>
<div class="symbol" style="-webkit-mask-image: url(common/symbols-black/volume.svg); mask-image: url(common/symbols-black/volume.svg);"></div>
</div>
</div>
<p data-translation="minVolumeNotice">Limit the minimum level of the volume slider.</p>

<div class="button margin-top pill grey" onclick="alsa_ttable.save();">Store Adjustments</div>
<p>Activate adjustments. This will stop the currently playing source.</p>

</div>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion Beocreate2/beo-extensions/alsaloop/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ var exec = require("child_process").exec;
enabled: enabled,
transportControls: ["play", "stop"],
startable: true,
usesHifiberryControl: true
usesHifiberryControl: true,
sortName: "Analogue Input"
});
});
}
Expand Down
2 changes: 1 addition & 1 deletion Beocreate2/beo-extensions/alsaloop/menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ <h1>Analogue Input</h1>
<div class="scroll-area">
<div class="menu-content">
<div class="menu-item toggle" id="alsaloop-enabled-toggle" onclick="alsaloop.toggleEnabled();">
<div class="menu-label">Enabled</div>
<div class="menu-label">On</div>
<div class="menu-toggle"></div>
</div>
<hr>
Expand Down
14 changes: 8 additions & 6 deletions Beocreate2/beo-extensions/beosonic/beosonic-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,15 @@ function updateBeosonicUI() {

// Dot & glow:
$("#beosonic-glow, #beosonic-dot").css("left", x+50+"%").css("top", 50-y+"%");
$("#beosonic-area").css("box-shadow", "0 3px 15px rgba(0, 0, 0, 0.2), "+x+"px "+(y*-1)+"px 50px #1e998d");


// Feeling labels:
if (beosonicDistance == 0) {
opacity = [1,1,1,1];
opacityDiag = [0.25,0.25,0.25,0.25];
opacityDiag = [0.0,0.0,0.0,0.0];
$("#beosonic-area").css("box-shadow", "0 3px 15px rgba(0, 0, 0, 0.1)");
} else {
$("#beosonic-area").css("box-shadow", "0 3px 15px rgba(0, 0, 0, 0.1), "+x+"px "+(y*-1)+"px "+(10+(beosonicDistance/50)*40)+"px hsl("+Math.round(beosonicAngle-105)+", 65%, 50%)");
opacityEffect = beosonicDistance/50;
[offset, quadrant] = getOffsetAndQuadrant(beosonicDistance, beosonicAngle); // For main labels.

Expand All @@ -203,10 +205,10 @@ function updateBeosonicUI() {

[offsetDiag, quadrantDiag] = getOffsetAndQuadrant(beosonicDistance, beosonicAngle, -45); // For diagonal labels.
oDiag = [ // Opacity:
0.25+0.75*opacityEffect, // Current
0.25-0.25*opacityEffect, // Opposite
(offsetDiag > 0) ? 0.25+(0.75*offsetDiag)*opacityEffect : 0.25+(offsetDiag*0.25)*opacityEffect, // Neighbour CCW
(offsetDiag > 0) ? 0.25+(-offsetDiag*0.25)*opacityEffect : 0.25+(0.75*-offsetDiag)*opacityEffect // Neighbour CW
0.0+0.75*opacityEffect, // Current
0.0-0.25*opacityEffect, // Opposite
(offsetDiag > 0) ? 0.0+(0.75*offsetDiag)*opacityEffect : 0.0+(offsetDiag*0.25)*opacityEffect, // Neighbour CCW
(offsetDiag > 0) ? 0.0+(-offsetDiag*0.25)*opacityEffect : 0.0+(0.75*-offsetDiag)*opacityEffect // Neighbour CW
];
if (quadrantDiag == 0) {
opacityDiag = [oDiag[1], oDiag[0], oDiag[3], oDiag[2]]; // NW, SE, SW, NE
Expand Down
70 changes: 56 additions & 14 deletions Beocreate2/beo-extensions/beosonic/beosonic.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,53 +11,96 @@
}

#beosonic-area {
background-color: #022c27;
/*background-color: #022c27;*/
border-radius: 50%;
background-size: 75%;
background-repeat: no-repeat;
background-position: center;
box-shadow: 0 3px 15px rgba(0, 0, 0, 0.3), 0 0 50px #057a7a;
box-shadow: 0 3px 15px rgba(0, 0, 0, 0.1);
position: absolute;
width: 100%;
height: 100%;
top: 0;
transition: box-shadow 1s cubic-bezier(.18,0,0,1);
overflow: hidden;
/*overflow: hidden;*/
/*background-color: var(--ultra-light-grey);*/
}

#beosonic-area:before {
content: "";
position: absolute;
width: 60px;
height: 60px;
background-color: var(--menu-line);
top: 50%;
left: 50%;
margin-top: -30px;
margin-left: -30px;
border-radius: 50%;
opacity: 0;
transition: opacity 0.5s ease;
}

.drag #beosonic-area:before {
opacity: 1;
}

.dark #beosonic-area {
background-color: #2a2a2a;
}

#beosonic-area:after {
content: "";
position: absolute;
border: 1px solid var(--alternate-bg);
top: -1px;
right: -1px;
left: -1px;
bottom: -1px;
border-radius: 50%;
}

.dark #beosonic-area:after {
border: 1px solid var(--menu-line);
}

#beosonic-glow {
background-image: radial-gradient(circle closest-side, #2CD5C4 0%, rgba(43, 213, 196, 0.8) 0%, rgba(41, 213, 196, 0.74) 13.4%, rgba(40, 213, 196, 0.11) 80.6%, rgba(41, 213, 196, 0.04) 90%, rgba(43, 213, 196, 0) 100%);
/*background-image: radial-gradient(circle closest-side, #2CD5C4 0%, rgba(43, 213, 196, 0.8) 0%, rgba(41, 213, 196, 0.74) 13.4%, rgba(40, 213, 196, 0.11) 80.6%, rgba(41, 213, 196, 0.04) 90%, rgba(43, 213, 196, 0) 100%);*/
background-image: radial-gradient(circle closest-side, white 0%, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0.74) 13.4%, rgba(255, 255, 255, 0.11) 80.6%, rgba(255, 255, 255, 0.04) 90%, rgba(255, 255, 255, 0) 100%);
opacity: 0.3;
position: absolute;
mix-blend-mode: screen;
width: 100%;
height: 100%;
margin-top: -50%;
margin-left: -50%;
width: 60%;
height: 60%;
margin-top: -30%;
margin-left: -30%;
top: 50%;
left: 50%;
transition: top 1s cubic-bezier(.18,0,0,1), left 1s cubic-bezier(.18,0,0,1);
display: none;
}

#beosonic-dot {
width: 60px;
height: 60px;
background-color: white;
background-color: currentColor;
top: 50%;
position: absolute;
left: 50%;
margin-top: -30px;
margin-left: -30px;
border-radius: 50%;
box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18), 0 1px 3px rgba(0, 0, 0, 0.3);
opacity: 0.8;
box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
transition: box-shadow 0.5s ease, left 0.3s ease, top 0.3s ease, color 0.5s ease, width 0.3s ease, height 0.3s ease, margin-left 0.3s ease, margin-top 0.3s ease, font-size 0.3s ease, transform 0.5s ease, background-color 0.5s ease;
cursor: move;
}

#beosonic-dot:active {
transition: box-shadow 0.2s ease, color 0.3s ease, transform 0.2s ease;
/*transform: scale(1.1);*/
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.3);
background-color: #eee;
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
/*background-color: #eee;*/
}

.beosonic-label {
Expand All @@ -78,7 +121,6 @@
font-weight: 500;
height: 20px;
width: 100px;
color: white;
}

.beosonic-label.left,
Expand Down Expand Up @@ -118,7 +160,7 @@
justify-content: center;
font-size: 0.8em;
width: 40px;
color: rgba(255, 255, 255, 0.5);
color: gray;
height: 40px;
margin-left: -20px;
margin-top: -20px;
Expand Down
9 changes: 8 additions & 1 deletion Beocreate2/beo-extensions/beosonic/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ beo.bus.on('beosonic', function(event) {

}

if (event.header == "logTesti") {

console.log(fullPresetList.testi.channels);

}

});

beo.bus.on('dsp', function(event) {
Expand Down Expand Up @@ -428,7 +434,8 @@ function savePresetToFile(withName, withAdjustments) {
if (withAdjustments[a] != "beosonic") {
if (beo.extensions[withAdjustments[a]] &&
beo.extensions[withAdjustments[a]].getSettingsForBeosonic) {
fullPresetList[newID][withAdjustments[a]] = beo.extensions[withAdjustments[a]].getSettingsForBeosonic();
adjustmentSettings = beo.extensions[withAdjustments[a]].getSettingsForBeosonic();
fullPresetList[newID][withAdjustments[a]] = JSON.parse(JSON.stringify(adjustmentSettings));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Beocreate2/beo-extensions/beosonic/menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ <h1>Listening Mode</h1>
<div class="menu-content">
<div id="beosonic-control">
<img class="square-helper" src="common/square-helper.png">
<div id="beosonic-area" style="background-image: url(€/beosonic-circles.svg);">
<div id="beosonic-area"> <!--style="background-image: url(€/beosonic-circles.svg);"-->
<div id="beosonic-glow"></div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion Beocreate2/beo-extensions/beosonic/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@beocreate/beosonic",
"version": "0.6",
"version": "0.6.2",
"description": "Tone controls for Beocreate sound systems.",
"main": "index.js",
"scripts": {
Expand Down
Loading

0 comments on commit 7324b7c

Please sign in to comment.