4
4
import { AdditiveSynth , setHarmonics , setSpectra } from ' $lib/audio/audio'
5
5
import { Keyboard } from ' $lib/controllers/keyboard'
6
6
import { EventEmitter } from ' $lib/common/event-emitter'
7
-
7
+ import partials from ' $lib/audio/partials.json'
8
+
8
9
const noteEmitter = new EventEmitter ()
9
10
const controller = new Keyboard ()
10
11
const synth = new AdditiveSynth ()
11
12
let isMobileDevice: boolean = false
13
+ let selectedPartials = ' harmonics'
12
14
13
15
controller .enable (noteEmitter )
14
16
15
17
onMount (async () => {
16
18
await synth .initialize (noteEmitter )
17
19
})
18
20
19
-
20
21
const setDevice = () => {
21
22
if (window .innerWidth <= 768 ) {
22
- isMobileDevice = true
23
+ isMobileDevice = true
23
24
} else {
24
25
isMobileDevice = false
25
26
}
26
27
}
27
28
29
+ $ : {
30
+ if (selectedPartials === ' harmonics' ) {
31
+ setHarmonics ()
32
+ } else {
33
+ setSpectra ()
34
+ }
35
+ }
36
+
28
37
setDevice ()
29
38
</script >
30
39
31
40
<svelte:window on:resize ={setDevice } />
32
41
33
- <h2 >Quick demo of Harmonics vs 12-ED2 Spectra</h2 >
34
- <button on:click ={synth .start }>Start</button >
35
- <button on:click ={setHarmonics }>Harmonics</button >
36
- <button on:click ={setSpectra }>Spectra</button >
37
- <div class =" row" >
38
- Harmonic multipliers
39
- <code >[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]</code >
40
- </div >
41
- <div class =" row" >
42
- Spectral multipliers
43
- <code >[1, 2, 2.997, 4, 5.04, 5.993, 7.127, 8, 8.98, 10.079, 11.314, 11.986, 12.699, 14.254, 15.102, 16]</code >
44
- </div >
45
- <div class =" row" >
46
- Amplitudes
47
- <code >[0.1, 0.09, 0.08, 0.07, 0.06, 0.05, 0.04, 0.03,0.02, 0.01, 0.009, 0.008, 0.007, 0.006, 0.005, 0.004]</code >
42
+ <div class =" grid grid-flow-row auto-rows-max justify-center bg-neutral h-screen p-10 text-base-content" >
43
+ <div class =" card w-full bg-base-100 shadow-xl" >
44
+ <div class =" card-body" >
45
+ <h1 class =" text-4xl pb-7" >Coincident Spectra</h1 >
46
+ <div class =" grid grid-flow-row auto-rows-max gap-7" >
47
+ <div class =" grid grid-flow-col auto-cols-max gap-4" >
48
+ <button class ="btn btn-primary" on:click ={synth .start }>
49
+ Start Audio
50
+ </button >
51
+ <select class =" select w-full max-w-xs select-primary" >
52
+ <option disabled selected >Tuning System</option >
53
+ <option value =" 12-ed2" >12-ED2</option >
54
+ <option value =" 19-ed2" >19-ED2</option >
55
+ </select >
56
+ <select class ="select w-full max-w-xs select-primary" bind:value ={selectedPartials }>
57
+ <option value =" harmonics" >Harmonics</option >
58
+ <option value =" spectra" >Spectra</option >
59
+ </select >
60
+ <select class =" select w-full max-w-xs select-primary" >
61
+ <option disabled selected >Controller</option >
62
+ <option >Keyboard</option >
63
+ <option >MIDI</option >
64
+ </select >
65
+ <select class =" select w-full max-w-xs select-primary" >
66
+ <option disabled selected >MIDI Device</option >
67
+ <option >Arturia Keystep</option >
68
+ <option >Roland Keyboard</option >
69
+ </select >
70
+ </div >
71
+ <div class =" overflow-x-auto" >
72
+ <table class =" table table-compact w-full" >
73
+ <thead >
74
+ <tr >
75
+ <th >Partial</th >
76
+ <th >Harmonics</th >
77
+ <th >Spectra</th >
78
+ <th >Gain</th >
79
+ </tr >
80
+ </thead >
81
+ <tbody >
82
+ {#each partials .harmonics as harmonic , index }
83
+ <tr >
84
+ <th >1</th >
85
+ <td >{harmonic }</td >
86
+ <td >{partials .spectra [index ]}</td >
87
+ <td >
88
+ <input
89
+ type =" range"
90
+ min =" 0"
91
+ max =" 100"
92
+ value =" 40"
93
+ class =" range range-xs"
94
+ />
95
+ </td >
96
+ </tr >
97
+ {/each }
98
+ </tbody >
99
+ </table >
100
+ </div >
101
+ </div >
102
+ </div >
103
+ </div >
48
104
</div >
49
105
50
106
<style >
51
- .row {
52
- padding-top : 1rem
53
- }
54
-
55
- </style >
107
+ </style >
0 commit comments