You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: user_guide/docs/index.md
+163-4Lines changed: 163 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,17 +24,17 @@ To install this into your Eurorack setup:
24
24
Big Honking Button has two inputs:
25
25
26
26
- A gate / trigger in
27
-
- A pitch CV in that is 1v/Oct with a -5v to +5v range<sup>see note</sup>
27
+
- A pitch CV in that is 1v/Oct with a `-5v` to `+5v` range<sup>see note</sup>
28
28
29
29
And two outputs:
30
30
31
-
- A gate / trigger out (0v or 5v)
31
+
- A gate / trigger out (`0v` or `5v`)
32
32
- An audio out
33
33
34
34
With the default code, it will trigger the sample and play it through the audio out whenever the button is pressed or whenever the gate input is triggered. It will also set the gate out to high whenever the button is pressed or whenever the gate in is high. You can customize some of this behavior by [modifying the code](#modifying-the-code).
35
35
36
36
!!! note "Revision differences"
37
-
Big Honking Buttons manufactured prior to 2021 (marked v4 on the backside) only have an input range of -2v to +2v. More than that won't damage the module, but it won't be able to measure anything outside of that range.
37
+
Big Honking Buttons manufactured prior to 2021 (marked v4 on the backside) only have an input range of `-2v` to `+2v`. More than that won't damage the module, but it won't be able to measure anything outside of that range.
38
38
39
39
## Changing the sample
40
40
@@ -91,7 +91,7 @@ Okay, save the file! Your Big Honking Button should restart and now it should st
91
91
92
92
**Congrats**, you've made your first change to how the module works! 🎉
93
93
94
-
Big Honking Button can store multiple samples and you can use various means to change how they're triggered. We'll be adding a sample showing just that soon, but don't be afraid to experiment and reach out if you need any help!
94
+
Big Honking Button can do all sorts of neat stuff by changing its code. Check out the [examples](#examples) or jump in the deep end with the [code reference](#code-reference). Don't be afraid to experiment and reach out if you need any help!
95
95
96
96
If you want to you can learn more about [CircuitPython](https://learn.adafruit.com/welcome-to-circuitpython/overview) to the most of your module. Also, please come chat on the [Discord][discord] where you can ask questions and see what others are doing with their Big Honking Button!
97
97
@@ -115,6 +115,8 @@ To use these examples, connect your Big Honking Button to your computer just lik
115
115
1.[Sine example](https://github.com/wntrblm/Big_Honking_Button/blob/main/examples/sine.py): An advanced example that shows how to generate a custom waveform.
116
116
1.[Noise example](https://github.com/wntrblm/Big_Honking_Button/blob/main/examples/noise.py): An advanced example that shows how to generate noise.
117
117
118
+
If you're ready to go beyond the examples, check out the [code reference](#code-reference).
119
+
118
120
## Help! I changed some code and this thing isn't working!
119
121
120
122
There's probably some sort of error in the program. Don't worry, you can get it figured out.
@@ -123,6 +125,163 @@ If you connect using the [serial console](https://learn.adafruit.com/welcome-to-
123
125
124
126
In any case, reach out on [Discord][discord] and we can walk you through figuring out what went wrong.
125
127
128
+
## Code reference
129
+
130
+
Big Honking Button runs [CircuitPython](https://circuitpython.org) and provides a helpful `BigHonkingButton` class for accessing the hardware and features. The first thing that you'll do in your code is import that class and create an instance:
131
+
132
+
```python
133
+
import winterbloom_bhb
134
+
135
+
bhb = winterbloom.BigHonkingButton()
136
+
```
137
+
138
+
In a lot of cases, the first thing you'll do with the `bhb` instance is load some samples:
139
+
140
+
```python
141
+
honk = bhb.load_sample("samples/honk.wav")
142
+
clap = bhb.load_sample("samples/clap.wav")
143
+
```
144
+
145
+
Once you're all set up, you'll start the **update loop**:
146
+
147
+
```python
148
+
while bhb.update():
149
+
...
150
+
```
151
+
152
+
This loop will repeat over and over. Each time the loop is run, `bhb.update()` is called and it will read in the state of the button, gate in, and CV input. You have to call `bhb.update()` otherwise it won't ever know if things change!
153
+
154
+
### Inputs
155
+
156
+
While inside the loop you can check the state of the various inputs. First, you can check if **either** the button has been pressed **or** the gate in has gone from low to high:
157
+
158
+
```python
159
+
if bhb.triggered:
160
+
...
161
+
```
162
+
163
+
Similarly, you can check if **either** the button has been released **or** the gate has gone from high to low:
164
+
165
+
```python
166
+
if bhb.released:
167
+
...
168
+
```
169
+
170
+
These two states are demonstrated in the [default example](https://github.com/wntrblm/Big_Honking_Button/blob/main/examples/default.py):
171
+
172
+
```python
173
+
while bhb.update():
174
+
if bhb.triggered:
175
+
bhb.play("honk.wav")
176
+
177
+
elif bhb.released:
178
+
bhb.stop()
179
+
```
180
+
181
+
You can get more specific by checking the button and gate independently. You
182
+
can use the `button` property to check the button:
183
+
184
+
```python
185
+
if bhb.button.pressed:
186
+
# Button was just pressed.
187
+
...
188
+
189
+
if bhb.button.released:
190
+
# Button was just released.
191
+
...
192
+
193
+
if bhb.button:
194
+
# Button is held down.
195
+
```
196
+
197
+
Likewise, you can use the `gate_in` property to check the gate input:
198
+
199
+
```python
200
+
if bhb.gate_in.rising_edge:
201
+
# Gate in just moved from low to high.
202
+
...
203
+
204
+
if bhb.gate_in.falling_edge:
205
+
# Gate in just moved from high to low.
206
+
...
207
+
208
+
if bhb.gate_in:
209
+
# The gate input is being held high.
210
+
```
211
+
212
+
!!! Note "Aliases"
213
+
For convenience, `bhb.button` and `bhb.gate_in` have property aliases. `.pressed`, `.rising_edge`, and `.triggered` are all the same, likewise, `.released` and `.falling_edge` are the same.
214
+
215
+
The pitch CV input is a little different. You can use `bhb.pitch_in` to read the *voltage* on the pitch CV input. Remember, the input range is `-5v` to `+5v`.
216
+
217
+
```python
218
+
if bhb.pitch_in >0:
219
+
...
220
+
```
221
+
222
+
More usefully you can use the pitch input to re-pitch the sample:
223
+
224
+
```
225
+
bhb.play(honk, pitch_cv=bhb.pitch_in)
226
+
```
227
+
228
+
There are other ways you can use the CV input, for instance, the [CV select example](https://github.com/wntrblm/Big_Honking_Button/blob/main/examples/cv_select.py) uses it to select from a list of samples.
229
+
230
+
231
+
### Outputs
232
+
233
+
Big Honking Button has two outputs: an audio out and a gate out. The audio out can be used to play previously-loaded samples:
234
+
235
+
```python
236
+
bhb.play(honk)
237
+
```
238
+
239
+
It can also play the sample repeatedly:
240
+
241
+
```python
242
+
bhb.play(honk, repeat=True)
243
+
```
244
+
245
+
And re-pitch the sample:
246
+
247
+
```python
248
+
# Play at twice the frequency
249
+
bhb.play(honk, pitch_cv=2.0)
250
+
251
+
# Play at half the frequency
252
+
bhb.play(honk, pitch_cv=0.5)
253
+
254
+
# Play at normal pitch
255
+
bhb.play(honk, pitch_cv=1.0)
256
+
```
257
+
258
+
By default, the sample will play all the way through. If you want to stop the
259
+
sample you can use `bhb.stop()`:
260
+
261
+
262
+
```python
263
+
if bhb.pressed:
264
+
bhb.play(some_long_sample)
265
+
266
+
elif bhb.released:
267
+
bhb.stop()
268
+
```
269
+
270
+
When `stop()` is called the sample stops playing immediately - even if its in the middle of playback. If you play a new sample while a sample is playing, the old sample will stop immediately and the new one will start playing.
271
+
272
+
Finally, there's the gate out:
273
+
274
+
```python
275
+
if bhb.pressed:
276
+
# Sets the output to +5v
277
+
bhb.gate_out =True
278
+
279
+
elif bhb.released:
280
+
# Sets the output to 0v
281
+
bhb.gate_out =False
282
+
```
283
+
284
+
126
285
## Updating the firmware
127
286
128
287
Updating the firmware requires two steps: Updating CircuitPython and updating Big Honking Button's libraries.
0 commit comments