Skip to content

Commit

Permalink
Better communication of errors
Browse files Browse the repository at this point in the history
Includes relevant error messages when room compensation filters can't
be applied in following situations:
- the sound device does not include a DSP (measurement previews only)
- there is a problem with the DSP program
  • Loading branch information
tuomashamalainen committed Dec 12, 2020
1 parent 87a306b commit 3836361
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 10 deletions.
24 changes: 20 additions & 4 deletions Beocreate2/beo-extensions/room-compensation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var debug = beo.debug;

var defaultSettings = {
sampleCount: 4,
filterCount: 10,
noiseType: "white",
measureWithSoundDesign: false
}
Expand All @@ -44,6 +45,7 @@ var roomEQURL = null;
var xUUID = null;

var Fs = null;
var capabilities = 0;

beo.bus.on('general', function(event) {

Expand All @@ -56,8 +58,8 @@ beo.bus.on('general', function(event) {

if (event.header == "activatedExtension") {
if (event.content.extension == "room-compensation") {

beo.sendToUI("room-compensation", {header: "measurementsAndPresets", content: {measurements: compactMeasurementList, presets: presets}});
getCapabilities();
beo.sendToUI("room-compensation", {header: "measurementsAndPresets", content: {measurements: compactMeasurementList, presets: presets, capabilities: capabilities}});
}
}
});
Expand Down Expand Up @@ -465,15 +467,15 @@ function createAndSaveCompensation(measurement, type, speakerModel = null) {
// Save speaker model to the measurement.
measurements[measurement].speakerModel = speakerModel;
fs.writeFileSync(arcDirectory+"/measurements/"+measurement+".json", JSON.stringify(measurements[measurement]));
if (debug) console.log("Updated measurement '"+measurement+" with speaker model '"+speakerModel+"'.");
if (debug) console.log("Updated measurement '"+measurement+"' with speaker model '"+speakerModel+"'.");
}
uploadData = {
measurement: {
f: [], db: [], phase: []
},
curve: type,
optimizer: "smooth",
filtercount: 10,
filtercount: settings.filterCount,
"speaker-model": speakerModel,
samplerate: Fs,
settings: {
Expand Down Expand Up @@ -606,6 +608,20 @@ function deletePreset(preset, noUpdate = false) {
if (!noUpdate) beo.sendToUI("room-compensation", {header: "presets", content: {presets: presets}});
}

function getCapabilities() {
capabilities = 0;
if (beo.systemConfiguration.cardFeatures &&
beo.systemConfiguration.cardFeatures.indexOf("dsp") != -1) {
// DSP is available.
capabilities = 1;
}
if (beo.extensions.equaliser &&
beo.extensions.equaliser.canDoRoomCompensation) {
// Check if enough filters are available.
if (beo.extensions.equaliser.canDoRoomCompensation(settings.filterCount)) capabilities = 2;
}
}


function roomEQAPIRequest(endpoint, data, callback) {
if (!roomEQURL) getRoomEQConfig();
Expand Down
19 changes: 19 additions & 0 deletions Beocreate2/beo-extensions/room-compensation/menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,25 @@ <h2>What you need</h2>
<div class="button pill black cancel default" onclick="beo.ask();">Dismiss</div>
</div>
</div>

<div class="ask-menu" id="room-compensation-dsp-required-prompt">
<h2>DSP needed</h2>
<p>To use room compensation filters, a sound device with DSP is required (such as DAC+ DSP or Beocreate 4-Channel Amplifier).</p>
<div class="ask-buttons">
<a href="http:https://hifiberry.com/shop" target="_blank" class="button pill grey">View Products in Shop</a>
<div class="button pill black cancel default" onclick="beo.ask();">Dismiss</div>
</div>
</div>

<div class="ask-menu" id="room-compensation-dsp-problem-prompt">
<h2>Problem with sound processor</h2>
<p>Room compensation filters can't be used because there is a problem with the current DSP program. Known sampling rate and support for parametric equaliser (Sound Design) are required.</p>
<p>In the DSP Programs menu, please check which program is active and, if necessary, install the default DSP program for your sound device. Then try again.</p>
<div class="ask-buttons">
<div class="button pill black default" onclick="room_compensation.goToDSPPrograms();">Show DSP Programs</div>
<div class="button pill grey cancel" onclick="beo.ask();">Dismiss</div>
</div>
</div>
</div>

<script type="text/javascript" charset="utf-8" src="€/room-compensation-client.js"></script>
2 changes: 1 addition & 1 deletion Beocreate2/beo-extensions/room-compensation/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@beocreate/room-compensation",
"version": "0.7.0",
"version": "0.7.1",
"description": "Room compensation user interface for Beocreate 2 / HiFiBerryOS",
"main": "index.js",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var selectedMeasurement = null;
var measureStep = 0;

var Fs = null;
var capabilities = 0;

var recognisedCurves = {
"room_only": {
Expand Down Expand Up @@ -53,6 +54,11 @@ $(document).on("room-compensation", function(event, data) {
data.header == "measurements" ||
data.header == "presets") {


if (data.content.capabilities != undefined) {
capabilities = data.content.capabilities;
}

if (data.content.measurements) {
measurements = data.content.measurements;
$("#room-compensation-measurements").empty();
Expand Down Expand Up @@ -240,7 +246,7 @@ $(document).on("room-compensation", function(event, data) {
if (compensation.speakerModel) $(".room-compensation-details").append(beo.createMenuItem({label: "Speaker type", value: compensation.speakerModel, static: true}));
if (compensation.compensationID) $(".room-compensation-details").append(beo.createMenuItem({label: "Compensation ID", value: compensation.compensationID, static: true}));
if (!compensationGraph) {
compensationGraph = new Beograph("room-compensation-graph", {resolution: 256, colours: ["#2CD5C4", "#FF3E46", "#000000"], coloursDark: ["#2CD5C4", "#FF3E46", "#FFFFFF"], labels: {frequency: true, gain: true}});
compensationGraph = new Beograph("room-compensation-graph", {resolution: 256, colours: ["#2CD5C4", "#FF3E46", "#000000"], coloursDark: ["#2CD5C4", "#FF3E46", "#FFFFFF"], labels: {frequency: true, gain: true}, scale: 20});
}
if (compensation.filters) {
compensationGraph.store([0], {clearData: true});
Expand Down Expand Up @@ -393,10 +399,20 @@ function newCompensation(measurement = selectedMeasurement, type = null) {
} else {
askForSpeakerModel = false;
if (measurement) {
beo.sendToProduct("room-compensation", {header: "newCompensation", content: {fromMeasurement: measurement}});
switch (capabilities) {
case 2:
beo.sendToProduct("room-compensation", {header: "newCompensation", content: {fromMeasurement: measurement}});
break;
case 1:
beo.ask("room-compensation-dsp-problem-prompt");
break;
case 0:
beo.ask("room-compensation-dsp-required-prompt");
break;
}
showMeasurement();
} else {
if (Object.keys(measurements).length > 0) {
if (Object.keys(measurements).length > 0 && capabilities > 0) {
$("#room-measurement-chooser").empty();
for (measurement in measurements) {
menuOptions = {
Expand Down Expand Up @@ -428,7 +444,17 @@ function applyCompensation(disable = false) {
if (disable && currentPreset != null) {
beo.sendToProduct("room-compensation", {header: "disableCompensation"});
} else if (selectedPreset) {
beo.sendToProduct("room-compensation", {header: "applyCompensation", content: {preset: selectedPreset, confirm: false}});
switch (capabilities) {
case 2:
beo.sendToProduct("room-compensation", {header: "applyCompensation", content: {preset: selectedPreset, confirm: false}});
break;
case 1:
beo.ask("room-compensation-dsp-problem-prompt");
break;
case 0:
beo.ask("room-compensation-dsp-required-prompt");
break;
}
showCompensation();
}
}
Expand All @@ -449,6 +475,11 @@ function deleteCompensation(confirmed) {
}
}

function goToDSPPrograms() {
beo.ask();
beo.showExtension("dsp-programs");
}


return {
newMeasurement: newMeasurement,
Expand All @@ -460,7 +491,9 @@ return {
newCompensation: newCompensation,
showCompensation: showCompensation,
applyCompensation: applyCompensation,
deleteCompensation: deleteCompensation
deleteCompensation: deleteCompensation,
goToDSPPrograms: goToDSPPrograms,
setCapabilities: function(level) {capabilities = level;}
}

})();

0 comments on commit 3836361

Please sign in to comment.