Преглед изворни кода

width -> pulseWidth

Change width to pulseWidth, update the example, keywords.txt and
gui/list.htm
dds
Nantonos пре 10 година
родитељ
комит
07919f1597
4 измењених фајлова са 12 додато и 7 уклоњено
  1. +3
    -3
      examples/Synthesis/pulseWidth/pulseWidth.ino
  2. +4
    -1
      gui/list.html
  3. +3
    -1
      keywords.txt
  4. +2
    -2
      synth_waveform.h

examples/Synthesis/pulse/pulse.ino → examples/Synthesis/pulseWidth/pulseWidth.ino Прегледај датотеку

@@ -1,4 +1,4 @@
// demonstrate pulse with slow changes in width
// demonstrate pulse with slow changes in pulse width

#include <Audio.h>
#include <Wire.h>
@@ -24,7 +24,7 @@ void setup(void)
audioShield.enable();
audioShield.volume(0.45);

waveform1.width(0.5);
waveform1.pulseWidth(0.5);
waveform1.begin(0.4, 220, WAVEFORM_PULSE);

envelope1.attack(50);
@@ -38,7 +38,7 @@ void loop() {
float w;
for (uint32_t i =1; i<20; i++) {
w = i / 20.0;
waveform1.width(w);
waveform1.pulseWidth(w);
envelope1.noteOn();
delay(800);
envelope1.noteOff();

+ 4
- 1
gui/list.html Прегледај датотеку

@@ -760,7 +760,7 @@
</script>
<script type="text/x-red" data-help-name="AudioSynthWaveform">
<h3>Summary</h3>
<p>Create a waveform: sine, sawtooth, square, or triangle</p>
<p>Create a waveform: sine, sawtooth, square, triangle, pulse or arbitrary.</p>
<h3>Audio Connections</h3>
<table class=doc align=center cellpadding=3>
<tr class=top><th>Port</th><th>Purpose</th></tr>
@@ -787,6 +787,8 @@
<a href="http://www.pjrc.com/teensy/td_libs_AudioProcessorUsage.html" target="_blank">AudioNoInterrupts()</a>
should be used to guarantee all new settings take effect together.
</p>
<p class=func><span class=keyword>pulseWidth</span>(amount);</p>
<p class=desc>Change the width (duty cycle) of the pulse.</p>
<p class=func><span class=keyword>arbitraryWaveform</span>(array, maxFreq);</p>
<p class=desc>
Configure the waveform to be used with WAVEFORM_ARBITRARY. Array
@@ -804,6 +806,7 @@
<li><span class=literal>WAVEFORM_SQUARE</span></li>
<li><span class=literal>WAVEFORM_TRIANGLE</span></li>
<li><span class=literal>WAVEFORM_ARBITRARY</span></li>
<li><span class=literal>WAVEFORM_PULSE</span></li>
</ul>
</p>
</script>

+ 3
- 1
keywords.txt Прегледај датотеку

@@ -1,4 +1,4 @@
Audio KEYWORD2
Audio KEYWORD2
AudioConnection KEYWORD2
AudioInputI2S KEYWORD2
AudioOutputI2S KEYWORD2
@@ -46,6 +46,7 @@ frequency KEYWORD2
phase KEYWORD2
amplitude KEYWORD2
offset KEYWORD2
pulseWidth KEYWORD2
resonance KEYWORD2
octaveControl KEYWORD2
averageTogether KEYWORD2
@@ -133,4 +134,5 @@ WAVEFORM_SAWTOOTH LITERAL1
WAVEFORM_SQUARE LITERAL1
WAVEFORM_TRIANGLE LITERAL1
WAVEFORM_ARBITRARY LITERAL1
WAVEFORM_PULSE LITERAL1


+ 2
- 2
synth_waveform.h Прегледај датотеку

@@ -92,11 +92,11 @@ public:
else if (n > 1.0) n = 1.0;
tone_offset = n * 32767.0;
}
void width(float n) { // 0.0 to 1.0
void pulseWidth(float n) { // 0.0 to 1.0
if (n < 0) n = 0;
else if (n > 1.0) n = 1.0;
tone_width = n * 0x7fffffffLL;
// width is stored as the equivalent phase
// pulse width is stored as the equivalent phase
}
void begin(short t_type) {
tone_phase = 0;

Loading…
Откажи
Сачувај