Skip to content

Commit

Permalink
minor api tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Williamson committed Nov 2, 2021
1 parent f9ee8a4 commit b4c1308
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
16 changes: 16 additions & 0 deletions libraries/audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,22 @@ namespace picosystem {
uint32_t _duration;
uint32_t _volume = 100;

voice_t voice(uint32_t attack, uint32_t decay, uint32_t sustain,
uint32_t release, int32_t bend, uint32_t bend_ms,
uint32_t reverb, uint32_t noise, uint32_t distort) {
return {
.bend = bend,
.bend_ms = bend_ms,
.attack = attack,
.decay = decay,
.sustain = sustain,
.release = release,
.reverb = reverb,
.noise = noise,
.distort = distort
};
}

void play(voice_t voice,
uint32_t frequency, uint32_t duration, uint32_t volume) {
_frequency = frequency;
Expand Down
10 changes: 5 additions & 5 deletions libraries/picosystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ namespace picosystem {
color_t* ps, int32_t so, int32_t ss, color_t* pd, uint32_t c);

// audio
voice_t voice(
uint32_t attack = 100, uint32_t decay = 50,
uint32_t sustain = 80, uint32_t release = 100,
int32_t bend = 0, uint32_t bend_ms = 0, uint32_t reverb = 0,
uint32_t noise = 0, uint32_t distort = 0);
void play(
voice_t voice, uint32_t frequency,
uint32_t duration = 500, uint32_t volume = 100);
Expand All @@ -185,11 +190,6 @@ namespace picosystem {
color_t rgb(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 15);
color_t hsv(float h, float s, float v, float a = 1.0f);
buffer_t* buffer(uint32_t w, uint32_t h, void *data = nullptr);
voice_t voice(
uint32_t attack = 100, uint32_t decay = 50,
uint32_t sustain = 80, uint32_t release = 100,
int32_t bend = 0, uint32_t bend_ms = 0, uint32_t reverb = 0,
uint32_t noise = 0, uint32_t distort = 0);
uint32_t time();
uint32_t time_us();
void sleep(uint32_t d);
Expand Down
16 changes: 0 additions & 16 deletions libraries/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,6 @@ namespace picosystem {
return b;
}

voice_t voice(uint32_t attack, uint32_t decay, uint32_t sustain,
uint32_t release, int32_t bend, uint32_t bend_ms,
uint32_t reverb, uint32_t noise, uint32_t distort) {
return {
.bend = bend,
.bend_ms = bend_ms,
.attack = attack,
.decay = decay,
.sustain = sustain,
.release = release,
.reverb = reverb,
.noise = noise,
.distort = distort
};
}

// returns true if the provided rectangles intersect
bool intersects(
int32_t x, int32_t y, int32_t w, int32_t h,
Expand Down

0 comments on commit b4c1308

Please sign in to comment.