-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathWVR.cpp
106 lines (88 loc) · 1.7 KB
/
WVR.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include "Arduino.h"
#include "WVR.h"
#include "wvr_0.3.h"
#include "wav_player.h"
#include "server.h"
#include "file_system.h"
#include "encoder.h"
#include "midi_in.h"
WVR::WVR()
{
this->wifiIsOn = get_wifi_is_on();
this->useFTDI = false;
this->useUsbMidi = false;
this->forceWifiOn = false;
this->checkRecoveryModePin = true;
}
void WVR::begin()
{
wvr_init(useFTDI, useUsbMidi, checkRecoveryModePin);
}
void WVR::play(uint8_t voice, uint8_t note, uint8_t velocity)
{
play_wav(voice,note,velocity);
}
void WVR::stop(uint8_t voice, uint8_t note)
{
stop_wav(voice,note);
}
void WVR::wifiOff()
{
if(get_wifi_is_on() == 1){
server_pause();
}
this->wifiIsOn = get_wifi_is_on();
}
void WVR::wifiOn()
{
if(get_wifi_is_on() == 0){
server_resume();
}
this->wifiIsOn = get_wifi_is_on();
}
void WVR::toggleWifi()
{
this->wifiIsOn ? wifiOff() : wifiOn();
// wifiIsOn = !wifiIsOn;
this->wifiIsOn = get_wifi_is_on();
}
void WVR::setGlobalVolume(uint8_t volume)
{
set_global_volume(volume);
}
uint8_t WVR::getGlobalVolume(void)
{
return get_global_volume();
}
void WVR::mute(void)
{
set_mute(true);
}
void WVR::unmute(void)
{
set_mute(false);
}
void WVR::setMidiHook(void(*fn)(uint8_t *in))
{
set_midi_hook(fn);
}
void WVR::encoderInit(int encA, int encB)
{
encoder_init(encA, encB);
}
void WVR::onEncoder(void (*handleEncoder)(bool up))
{
on_encoder = handleEncoder;
}
void WVR::resetPin(int pin)
{
gpio_reset_pin(gpioNumToGpioNum_T(pin));
}
uint8_t WVR::getVoice(int channel)
{
return get_channel_lut()[channel];
}
void WVR::setVoice(int channel, int voice)
{
get_channel_lut()[channel] = (voice & 0b00001111);
}