#include <Arduino.h>
#include <i2s_external.hpp>
#include <button.hpp>
#include <sfx.hpp>
#define GE_44_16_M_IMPLEMENTATION
#define GS_44_16_M_IMPLEMENTATION
#define GSS_44_16_M_IMPLEMENTATION
#define TEST2_IMPLEMENTATION
#include <GE_44_16_M.h>
#include <GS_44_16_M.h>
#include <GSS_44_16_M.h>
#include <test2.h>
using namespace arduino;
using namespace sfx;
#define BUTTON_A 12
using button_a_t = arduino::int_button<BUTTON_A,10,true>;
static button_a_t button_a;
constexpr static const int8_t button_a_pin = 12;
using audio_t = i2s_external < -1, 33, 25, 26, i2s_channels::both, true >;
audio_t sound;
performer<5> perform(sound);
const_buffer_stream gunshot(GE_44_16_M, sizeof(GE_44_16_M));
const_buffer_stream gunempty(GS_44_16_M, sizeof(GS_44_16_M));
const_buffer_stream gunsilenced(GSS_44_16_M, sizeof(GSS_44_16_M));
const_buffer_stream test(test2, sizeof(test2));
void on_pressed_changed(bool pressed, void* state) {
if(pressed) {
perform.wav(test,1,false);
}
}
int button_handles[3];
int sound_state;
void setup() {
Serial.begin(115200);
button_a.initialize();
button_a.on_pressed_changed(on_pressed_changed);
}
void loop() {
perform.update();
button_a.update();
}
#include <Arduino.h>
#include <i2s_external.hpp>
#include <sfx.hpp>
#include <button.hpp>
using namespace arduino;
using namespace sfx;
using audio_t = i2s_external < -1, 33, 25, 15, i2s_channels::both, true >;
#define GE_44_16_M_IMPLEMENTATION
#include <GE_44_16_M.h>
#define BUTTON_A 12
using button_a_t = arduino::int_button<BUTTON_A,10,true>;
static button_a_t button_a;
constexpr static const int8_t button_a_pin = 12;
audio_t sound;
const_buffer_stream stm(GE_44_16_M, sizeof(GE_44_16_M));
void on_pressed_changed(bool pressed, void* state) {
if(pressed) {
Serial.println("button pressed");
wav_file_source wav;
sfx_result r = wav_file_source::open(stm, &wav);
wav.loop(false);
mixer_source<1> mixer;
r = mixer_source<1>::create(&mixer);
mixer.track(0, &wav);
mixer.level(0, .5);
transport trans;
r = transport::create(sound, mixer, &trans);
while(trans.update()==sfx_result::success);
}
}
void setup() {
Serial.begin(115200);
button_a.initialize();
button_a.on_pressed_changed(on_pressed_changed);
}
void loop() {
button_a.update();
Serial.println("in loop");
}