Skip to content

Commit

Permalink
Fix unison not updating in synth designer
Browse files Browse the repository at this point in the history
  • Loading branch information
Ameobea committed Nov 24, 2024
1 parent dd2562f commit fbcaa7e
Show file tree
Hide file tree
Showing 3 changed files with 380 additions and 369 deletions.
24 changes: 24 additions & 0 deletions engine/wavetable/src/fm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,26 @@ impl OscillatorSource {
}
}

pub fn get_phase_count(&self) -> usize {
match self {
OscillatorSource::Wavetable(_) => 1,
OscillatorSource::ParamBuffer(_) => 0,
OscillatorSource::Sine(_) => 1,
OscillatorSource::ExponentialOscillator(_) => 1,
OscillatorSource::Square(_) => 1,
OscillatorSource::Triangle(_) => 1,
OscillatorSource::Sawtooth(_) => 1,
OscillatorSource::UnisonSine(osc) => osc.oscillators.len(),
OscillatorSource::UnisonWavetable(osc) => osc.oscillators.len(),
OscillatorSource::UnisonSquare(osc) => osc.oscillators.len(),
OscillatorSource::UnisonTriangle(osc) => osc.oscillators.len(),
OscillatorSource::UnisonSawtooth(osc) => osc.oscillators.len(),
OscillatorSource::SampleMapping(_) => 0,
OscillatorSource::TunedSample(_) => 0,
OscillatorSource::WhiteNoise(_) => 0,
}
}

pub fn set_phase(&mut self, new_phases: &[f32]) {
let new_phase = new_phases.get(0).copied().unwrap_or_default();
match self {
Expand Down Expand Up @@ -672,6 +692,10 @@ impl OscillatorSource {

/// Given a new operator source, if the new one is the same type as the old one, we
pub fn maybe_update(&mut self, other: &OscillatorSource) -> bool {
if self.get_phase_count() != other.get_phase_count() {
return false;
}

match self {
OscillatorSource::Sine(_) => false,
OscillatorSource::Wavetable(wt) =>
Expand Down
34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,38 @@
"repository": "https://github.com/Ameobea/web-synth",
"author": "Casey Primozic <[email protected]>",
"devDependencies": {
"@eslint/compat": "^1.2.1",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.13.0",
"@eslint/compat": "^1.2.3",
"@eslint/eslintrc": "^3.2.0",
"@eslint/js": "^9.15.0",
"@types/d3": "^7.4.3",
"@types/downloadjs": "^1.4.6",
"@types/node": "^22.7.7",
"@types/node": "^22.9.3",
"@types/react-window": "^1.8.8",
"@types/showdown": "^2.0.6",
"@typescript-eslint/eslint-plugin": "^8.10.0",
"@typescript-eslint/parser": "^8.10.0",
"@typescript-eslint/eslint-plugin": "^8.15.0",
"@typescript-eslint/parser": "^8.15.0",
"@webpack-cli/serve": "^2.0.5",
"css-loader": "^7.1",
"cypress": "^13.15.0",
"eslint": "^9.13.0",
"cypress": "^13.16.0",
"eslint": "^9.15.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-react": "^7.37.1",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-hooks": "^5.0.0",
"file-loader": "^6.2.0",
"globals": "^15.11.0",
"globals": "^15.12.0",
"handlebars": "^4.7.8",
"handlebars-loader": "^1.7.3",
"html-webpack-plugin": "^5.6",
"prettier": "^3.3.3",
"prettier-plugin-svelte": "^3.2.7",
"prettier-plugin-svelte": "^3.3.2",
"serve": "^14.2.4",
"style-loader": "^4.0.0",
"svelte-loader": "^3.2.4",
"svelte-preprocess": "^6.0.3",
"svg-inline-loader": "^0.8.2",
"ts-loader": "^9.5.1",
"typescript": "^5.6.3",
"webpack": "^5.95.0",
"typescript": "^5.7.2",
"webpack": "^5.96.1",
"webpack-bundle-analyzer": "^4.10.2",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^5.1"
Expand All @@ -64,18 +64,18 @@
"@pixi/sprite": "^7.4.2",
"@pixi/text": "^7.4.2",
"@reduxjs/toolkit": "^2.3.0",
"@sentry/react": "^8.34.0",
"@sentry/react": "^8.40.0",
"@types/ramda": "^0.30.2",
"@types/react": "^18.3.11",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@types/react-redux": "^7.1.34",
"@types/webmidi": "^2.1.0",
"ace-builds": "^1.36",
"chartist": "^1.3.0",
"comlink": "^4.4.1",
"comlink": "^4.4.2",
"d3": "^7.9.0",
"d3-scale-chromatic": "^3.1.0",
"dexie": "^4.0.8",
"dexie": "^4.0.10",
"downloadjs": "^1.4.7",
"funfix-core": "^7.0.1",
"immutable": "^4.3.7",
Expand Down
Loading

0 comments on commit fbcaa7e

Please sign in to comment.