Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasArvidsson committed Sep 30, 2022
2 parents 667dcd2 + 3574e55 commit 46a6cd0
Show file tree
Hide file tree
Showing 12 changed files with 11,533 additions and 87 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ By popular demand there now is a web based configuration editor. Gone are the da
"stereoBass": true,
"expandSurround": true,
"lfeGain": -3,
"centerGain": 3,
"lowPass": {
"type": "BUTTERWORTH",
"order": 5,
Expand Down Expand Up @@ -275,6 +276,8 @@ By popular demand there now is a web based configuration editor. Gone are the da
* lfeGain: Gain offset for mixing the LFE signal with other channels.
* Default value: 0
* Works with both subwoofers and front speakers.
* centerGain: Gain offset for mixing the center signal with other channels.
* Default value: 0
* lowPass: Filter configuration for low pass filter. Is applied to Sub channels.
* Default value: Butterworth 80Hz 5order(30dB/oct)
* highPass: Filter configuration for high pass filter. Is applied to Small channels.
Expand Down
11,466 changes: 11,441 additions & 25 deletions lib/ConfigEditor/package-lock.json

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions lib/ConfigEditor/pom.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.andreasarvidsson</groupId>
<artifactId>windsp-config-editor</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.0</version>
<packaging>war</packaging>
<name>WinDSP-configEditor</name>

Expand Down Expand Up @@ -46,10 +45,10 @@
</execution>
</executions>
<configuration>
<finalName>${project.name}</finalName>
<finalName>${project.name}</finalName>
</configuration>
</plugin>

<!-- Run npm -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
Expand All @@ -73,7 +72,7 @@
</execution>
</executions>
</plugin>

</plugins>
</build>

Expand All @@ -84,6 +83,6 @@
<version>8.0</version>
<scope>provided</scope>
</dependency>

</dependencies>
</project>
83 changes: 49 additions & 34 deletions lib/ConfigEditor/srcWeb/inputs/Dropdown.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,58 @@

import React from "react";
import PropTypes from "prop-types";
import InputBase from "./InputBase";

export default class Dropdown extends InputBase {
static propTypes = {
json: PropTypes.object.isRequired,
field: PropTypes.string.isRequired,
label: PropTypes.string.isRequired,
values: PropTypes.array.isRequired,
onChange: PropTypes.func,
disabled: PropTypes.bool,
};

static propTypes = {
json: PropTypes.object.isRequired,
field: PropTypes.string.isRequired,
label: PropTypes.string.isRequired,
values: PropTypes.array.isRequired,
onChange: PropTypes.func,
disabled: PropTypes.bool
};

getInput = () => {
return (
<select
id={this.uuid}
className="custom-select"
disabled={this.props.disabled}
value={this.state.value}
onChange={e => this.onChange(e.target.value)}
>
{this.state.value === undefined && this.getMissingOption()}
{this.props.values.map(this.getOption)}
</select>
);
}
getInput = () => {
return (
<select
id={this.uuid}
className="custom-select"
disabled={this.props.disabled}
value={this.state.value}
onChange={(e) => {
// `e.target.value` is always a string. Find actual value.
const value = this.props.values
.map((v) => parseValue(v).value)
.find((v) => v == e.target.value);
this.onChange(value);
}}
>
{this.state.value === undefined && this.getMissingOption()}
{this.props.values.map(this.getOption)}
</select>
);
};

getMissingOption() {
return <option key={undefined} value={undefined}>Select value</option>;
}
getMissingOption() {
return (
<option key={undefined} value={undefined}>
Select value
</option>
);
}

getOption(v) {
if (typeof v === "object") {
return <option key={v.value} value={v.value}>{v.text}</option>;
}
return <option key={v} value={v}>{v}</option>;
}
getOption(v) {
const { text, value } = parseValue(v);
return (
<option key={value} value={value}>
{text}
</option>
);
}
}

}
function parseValue(v) {
return typeof v === "object"
? { text: v.text, value: v.value }
: { text: v, value: v };
}
1 change: 1 addition & 0 deletions lib/ConfigEditor/srcWeb/routing/BasicRouting.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const BasicRouting = ({ jsonContext }) => {
<Dropdown json={json} field="surround" label="Surround" values={values4} onChange={onChange} />
<Dropdown json={json} field="surroundBack" label="Surround back" values={values4} onChange={onChange} />
<Number json={json} field="lfeGain" label="LFE gain" onChange={onChange} />
<Number json={json} field="centerGain" label="Center gain" onChange={onChange} />
<Checkbox
json={json}
field={stereoBassFields}
Expand Down
Binary file modified release/WinDSP-configEditor.jar
Binary file not shown.
Binary file modified release/WinDSP.exe
Binary file not shown.
1 change: 1 addition & 0 deletions release/WinDSP.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"stereoBass": false,
"expandSurround": false,
"lfeGain": 0,
"centerGain": 0,
"lowPass": {
"type": "BUTTERWORTH",
"order": 5,
Expand Down
1 change: 1 addition & 0 deletions release/config_examples.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"stereoBass": true,
"expandSurround": true,
"lfeGain": -3,
"centerGain": 3,
"lowPass": {
"type": "BUTTERWORTH",
"order": 5,
Expand Down
6 changes: 3 additions & 3 deletions src/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ class Config {
void parseChannel(unordered_map<Channel, SpeakerType>& result, const shared_ptr<JsonNode>& pNode, const string& field, const vector<Channel>& channels, const vector<SpeakerType>& allowed, const string& path) const;
const vector<Channel> getChannelsByType(const unordered_map<Channel, SpeakerType>& channelsMap, const SpeakerType targetType) const;
const double getLfeGain(const shared_ptr<JsonNode>& pBasicNode, const bool useSubwoofers, const bool hasSmalls, const string& path) const;
void routeChannels(const unordered_map<Channel, SpeakerType>& channelsMap, const bool stereoBass, const vector<Channel> subs, const vector<Channel> subLs, const vector<Channel> subRs, const double lfeGain);
void addBassRoute(Input& input, const bool stereoBass, const vector<Channel> subs, const vector<Channel> subLs, const vector<Channel> subRs, const double lfeGain) const;
void routeChannels(const unordered_map<Channel, SpeakerType>& channelsMap, const bool stereoBass, const vector<Channel> subs, const vector<Channel> subLs, const vector<Channel> subRs, const double lfeGain, const double centerGain);
void addBassRoute(Input& input, const bool stereoBass, const vector<Channel> subs, const vector<Channel> subLs, const vector<Channel> subRs, const double lfeGain, const double centerGain = 0) const;
void addSwRoute(Input& input, const bool stereoBass, const vector<Channel> subs, const vector<Channel> subLs, const vector<Channel> subRs, const double gain) const;
void addFrontBassRoute(Input& input, const bool stereoBass, const double gain) const;
void addRoutes(Input& input, const vector<Channel> channels, const double gain) const;
void addRoute(Input& input, const Channel channel, const double gain = 0, const bool addLP = false) const;
const SpeakerType addRoute(const unordered_map<Channel, SpeakerType>& channelsMap, Input& input, const vector<Channel>& channels) const;
void downmix(const unordered_map<Channel, SpeakerType>& channelsMap, Input& input, const bool stereoBass, const vector<Channel> subs, const vector<Channel> subLs, const vector<Channel> subRs, const double lfeGain) const;
void downmix(const unordered_map<Channel, SpeakerType>& channelsMap, Input& input, const bool stereoBass, const vector<Channel> subs, const vector<Channel> subLs, const vector<Channel> subRs, const double lfeGain, const double centerGain) const;
const bool getUseSubwoofers(const vector<Channel>& subs, const vector<Channel>& subLs, const vector<Channel>& subRs) const;
void parseExpandSurround(const shared_ptr<JsonNode>& pBasicNode, const unordered_map<Channel, SpeakerType>& channelsMap, const string& path);
void addIfRoute(Input& input, const Channel channel) const;
Expand Down
44 changes: 27 additions & 17 deletions src/ConfigParserBasic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ void Config::parseBasic() {
const unordered_map<Channel, SpeakerType> channelsMap = parseChannels(pBasicNode, stereoBass, subs, subLs, subRs, smalls, path);
const bool useSubwoofers = getUseSubwoofers(subs, subLs, subRs);
const double lfeGain = getLfeGain(pBasicNode, useSubwoofers, smalls.size(), path);
const double centerGain = tryGetDoubleValue(pBasicNode, "centerGain", path);

//Parse crossover config
parseBasicCrossovers(pBasicNode, channelsMap, path);
//Route input to output channels
routeChannels(channelsMap, stereoBass, subs, subLs, subRs, lfeGain);
routeChannels(channelsMap, stereoBass, subs, subLs, subRs, lfeGain, centerGain);
//Add conditional routing to surrounds
parseExpandSurround(pBasicNode, channelsMap, path);
}
Expand Down Expand Up @@ -83,7 +84,7 @@ void Config::parseExpandSurround(const shared_ptr<JsonNode>& pBasicNode, const u
}
}

void Config::routeChannels(const unordered_map<Channel, SpeakerType>& channelsMap, const bool stereoBass, const vector<Channel> subs, const vector<Channel> subLs, const vector<Channel> subRs, const double lfeGain) {
void Config::routeChannels(const unordered_map<Channel, SpeakerType>& channelsMap, const bool stereoBass, const vector<Channel> subs, const vector<Channel> subLs, const vector<Channel> subRs, const double lfeGain, const double centerGain) {
for (size_t i = 0; i < _numChannelsIn; ++i) {
const Channel channel = (Channel)i;
Input input(channel);
Expand All @@ -100,15 +101,15 @@ void Config::routeChannels(const unordered_map<Channel, SpeakerType>& channelsMa
break;
//Downmix
case SpeakerType::OFF:
downmix(channelsMap, input, stereoBass, subs, subLs, subRs, lfeGain);
downmix(channelsMap, input, stereoBass, subs, subLs, subRs, lfeGain, centerGain);
break;
//Sub or downmix
case SpeakerType::SUB:
if (channel == Channel::SW) {
addSwRoute(input, stereoBass, subs, subLs, subRs, lfeGain);
}
else {
downmix(channelsMap, input, stereoBass, subs, subLs, subRs, lfeGain);
downmix(channelsMap, input, stereoBass, subs, subLs, subRs, lfeGain, centerGain);
}
break;
default:
Expand All @@ -118,7 +119,7 @@ void Config::routeChannels(const unordered_map<Channel, SpeakerType>& channelsMa
}
}

void Config::downmix(const unordered_map<Channel, SpeakerType>& channelsMap, Input& input, const bool stereoBass, const vector<Channel> subs, const vector<Channel> subLs, const vector<Channel> subRs, const double lfeGain) const {
void Config::downmix(const unordered_map<Channel, SpeakerType>& channelsMap, Input& input, const bool stereoBass, const vector<Channel> subs, const vector<Channel> subLs, const vector<Channel> subRs, const double lfeGain, const double centerGain) const {
SpeakerType type = SpeakerType::OFF;
switch (input.getChannel()) {
case Channel::SL:
Expand All @@ -133,11 +134,13 @@ void Config::downmix(const unordered_map<Channel, SpeakerType>& channelsMap, Inp
case Channel::SBR:
type = addRoute(channelsMap, input, { Channel::SR , Channel::R });
break;
case Channel::C:
addRoute(input, Channel::L, PHANTOM_CENTER_GAIN);
addRoute(input, Channel::R, PHANTOM_CENTER_GAIN);
case Channel::C: {
const double gain = PHANTOM_CENTER_GAIN + centerGain;
addRoute(input, Channel::L, gain);
addRoute(input, Channel::R, gain);
type = channelsMap.at(Channel::L);
break;
}
case Channel::SW:
type = SpeakerType::SMALL;
break;
Expand All @@ -146,13 +149,22 @@ void Config::downmix(const unordered_map<Channel, SpeakerType>& channelsMap, Inp
}
//Downmixed a small speaker. Add to subs as well.
if (type == SpeakerType::SMALL) {
addBassRoute(input, stereoBass, subs, subLs, subRs, lfeGain);
addBassRoute(input, stereoBass, subs, subLs, subRs, lfeGain, centerGain);
}
}

void Config::addBassRoute(Input& input, const bool stereoBass, const vector<Channel> subs, const vector<Channel> subLs, const vector<Channel> subRs, const double lfeGain) const {
const Channel channel = input.getChannel();
const double gain = (channel == Channel::SW ? lfeGain : 0);
void Config::addBassRoute(Input& input, const bool stereoBass, const vector<Channel> subs, const vector<Channel> subLs, const vector<Channel> subRs, const double lfeGain, const double centerGain) const {
double gain;
switch (input.getChannel()) {
case Channel::SW:
gain = lfeGain;
break;
case Channel::C:
gain = centerGain;
break;
default:
gain = 0;
}
if (getUseSubwoofers(subs, subLs, subRs)) {
addSwRoute(input, stereoBass, subs, subLs, subRs, gain);
}
Expand Down Expand Up @@ -370,11 +382,9 @@ const vector<Channel> Config::getChannelsByType(const unordered_map<Channel, Spe

const double Config::getLfeGain(const shared_ptr<JsonNode>& pBasicNode, const bool useSubwoofers, const bool hasSmalls, const string& path) const {
const double lfeGain = tryGetDoubleValue(pBasicNode, "lfeGain", path);
if (useSubwoofers) {
//Playing subwoofer and no small speakers. IE LFE is not going to get mixed with other channels.
if (!hasSmalls) {
return 0;
}
//Playing subwoofer and no small speakers. IE LFE is not going to get mixed with other channels.
if (useSubwoofers && !hasSmalls) {
return 0;
}
return lfeGain + LFE_GAIN;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
using std::exception;
using std::make_shared;

#define VERSION "0.22.0b"
#define VERSION "1.0.0"

#ifdef DEBUG
#include "MemoryManager.h"
Expand Down

0 comments on commit 46a6cd0

Please # to comment.