Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
flow3r firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dos
flow3r firmware
Commits
ba91539e
Verified
Commit
ba91539e
authored
1 year ago
by
dos
Browse files
Options
Downloads
Patches
Plain Diff
sim: fakes: Basic bl00mbox sampler implementation using pygame
parent
c3596934
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
docs/badge/programming.rst
+2
-3
2 additions, 3 deletions
docs/badge/programming.rst
sim/fakes/bl00mbox.py
+94
-25
94 additions, 25 deletions
sim/fakes/bl00mbox.py
with
96 additions
and
28 deletions
docs/badge/programming.rst
+
2
−
3
View file @
ba91539e
...
@@ -735,9 +735,8 @@ Currently the simulator supports the display, LEDs, the buttons, accelerometer
...
@@ -735,9 +735,8 @@ Currently the simulator supports the display, LEDs, the buttons, accelerometer
(in 2D) and some static input values from the gyroscope, temperature sensor and
(in 2D) and some static input values from the gyroscope, temperature sensor and
pressure sensor.
pressure sensor.
It does **not** support any audio API, and in fact currently doesn't even stub
It does **not** support most of the audio APIs. It also does not support
out the relevant API methods, so it will crash when attempting to run any Music
positional captouch APIs.
app. It also does not support positional captouch APIs.
To set the simulator up, clone the repository and prepare a Python virtual
To set the simulator up, clone the repository and prepare a Python virtual
environment with the required packages:
environment with the required packages:
...
...
This diff is collapsed.
Click to expand it.
sim/fakes/bl00mbox.py
+
94
−
25
View file @
ba91539e
class
tinysynth
:
import
pygame
def
__init__
(
self
,
a
):
from
_sim
import
path_replace
pass
def
decay_ms
(
self
,
a
):
pass
def
decay
(
self
,
a
):
class
_mock
(
list
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
pass
pass
def
waveform
(
self
,
a
):
def
__getattr__
(
self
,
attr
):
if
attr
in
[
"
tone
"
,
"
value
"
]:
return
0
if
attr
in
[
"
trigger_state
"
]:
return
lambda
*
args
:
0
return
_mock
()
def
__call__
(
self
,
*
args
,
**
kwargs
):
return
_mock
()
class
Channel
:
def
__init__
(
self
,
id
):
pass
pass
def
tone
(
self
,
note
):
def
new
(
self
,
a
,
*
args
,
**
kwargs
):
return
a
(
self
,
*
args
,
**
kwargs
)
def
clear
(
self
):
pass
pass
mixer
=
None
channel_num
=
0
volume
=
8000
class
_patches
(
_mock
):
class
sampler
(
_mock
):
class
Signals
(
_mock
):
class
Trigger
(
_mock
):
def
__init__
(
self
,
sampler
):
self
.
_sampler
=
sampler
def
start
(
self
):
def
start
(
self
):
pass
self
.
_sampler
.
_sound
.
set_volume
(
self
.
_sampler
.
_channel
.
volume
/
32767
)
self
.
_sampler
.
_sound
.
play
()
def
sustain
(
self
,
a
):
def
__init__
(
self
,
sampler
):
pass
self
.
_sampler
=
sampler
self
.
_trigger
=
patches
.
sampler
.
Signals
.
Trigger
(
sampler
)
def
attack_ms
(
self
,
a
):
@property
pass
def
trigger
(
self
):
return
self
.
_trigger
def
release_ms
(
self
,
a
):
@trigger.setter
def
trigger
(
self
,
val
):
pass
pass
def
volume
(
self
,
a
):
def
_convert_filename
(
self
,
filename
):
pass
if
filename
.
startswith
(
"
/flash/
"
)
or
filename
.
startswith
(
"
/sd/
"
):
return
filename
elif
filename
.
startswith
(
"
/
"
):
return
"
/flash/
"
+
filename
else
:
return
"
/flash/sys/samples/
"
+
filename
def
stop
(
self
):
def
__init__
(
self
,
channel
,
path
):
pass
if
type
(
path
)
==
int
:
self
.
_signals
=
_mock
()
return
self
.
_sound
=
pygame
.
mixer
.
Sound
(
path_replace
(
self
.
_convert_filename
(
path
)))
self
.
_signals
=
patches
.
sampler
.
Signals
(
self
)
self
.
_channel
=
channel
@property
def
signals
(
self
):
return
self
.
_signals
class
Channel
:
def
__init__
(
self
,
id
):
pass
def
clear
(
self
):
class
_helpers
(
_mock
):
pass
def
sct_to_note_name
(
self
,
sct
):
sct
=
sct
-
18367
+
100
octave
=
((
sct
+
9
*
200
)
//
2400
)
+
4
tones
=
[
"
A
"
,
"
Bb
"
,
"
B
"
,
"
C
"
,
"
Db
"
,
"
D
"
,
"
Eb
"
,
"
E
"
,
"
F
"
,
"
Gb
"
,
"
G
"
,
"
Ab
"
]
tone
=
tones
[(
sct
//
200
)
%
12
]
return
tone
+
str
(
octave
)
def
note_name_to_sct
(
self
,
name
):
tones
=
[
"
A
"
,
"
Bb
"
,
"
B
"
,
"
C
"
,
"
Db
"
,
"
D
"
,
"
Eb
"
,
"
E
"
,
"
F
"
,
"
Gb
"
,
"
G
"
,
"
Ab
"
]
semitones
=
tones
.
index
(
name
[
0
])
if
semitones
>
2
:
semitones
-=
12
if
name
[
1
]
==
"
b
"
:
octave
=
int
(
name
[
2
:])
semitones
-=
1
elif
name
[
1
]
==
"
#
"
:
octave
=
int
(
name
[
2
:])
semitones
+=
1
else
:
octave
=
int
(
name
[
1
:])
return
18367
+
(
octave
-
4
)
*
2400
+
(
200
*
semitones
)
def
sct_to_freq
(
sct
):
return
440
*
2
**
((
sct
-
18367
)
/
2400
)
plugins
=
_mock
()
patches
=
_patches
()
helpers
=
_helpers
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment