-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaudio-oscillator.html
108 lines (98 loc) · 2.78 KB
/
audio-oscillator.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../paper-tabs/paper-tabs.html">
<link rel="import" href="../core-dropdown-menu/core-dropdown-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../core-field/core-field.html">
<link rel="import" href="audio-node.html">
<link rel="import" href="file-loader.html">
<link rel="import" href="audio-param.html">
<polymer-element name="audio-oscillator" extends="audio-node">
<template>
<style>
#controls{
background:inherit;
}
#waveForm{
border-radius:15px 0 0 0;
margin:0 0 0 5px;
}
</style>
<shadow></shadow>
<file-loader src="{{src}}" on-file-read-complete="{{fileLoaded}}">
</file-loader>
<div id="controls" layout vertical flex>
<template bind="{{node}}">
<audio-param id="frequencyNode" node="{{frequency}}" file="{{file}}" track="{{track}}">
</audio-param>
<audio-param id="detuneNode" node="{{detune}}">
</audio-param>
</template>
<core-dropdown-menu id="waveForm" flex selected="{{type}}" valueattr="label">
<core-item label="sine"></core-item>
<core-item label="triangle"></core-item>
<core-item label="sawtooth"></core-item>
<core-item label="square"></core-item>
</core-dropdown-menu>
</div>
</template>
<script>Polymer((function static(){
const sfx = window["::sfx::"];
const METHODS = {
start:{
value:function(){
this.node.start();
return this;
}
},
stop:{
value:function(){
this.node.stop();
return this;
}
},
setPeriodicWave:{
value:function(){
this.node.setPeriodicWave();
return this;
}
},
};
const PROTOTYPE = {
publish:{
track:0,
src:"",
type:"sine",
frequency:0,
detune:0,
},
frequencyChanged:function(o,n){
this.node.frequency.value = n;
},
detuneChanged:function(o,n){
this.node.detune.value = n;
},
typeChanged:function(o,n){
this.node.type = n;
},
ready:function(){
this.node = sfx.createOscillator();
this.color ="#49F";
this.start();
this.super();
},
attached:function(){
this.connect(this.parentElement);
},
fileLoaded:function(e,d,t){
this.node.file = d;
this.node.track = this.track;
}
};
Object.defineProperties(PROTOTYPE,METHODS);
return PROTOTYPE;
})());
/*
*/</script>
</polymer-element>