Skip to content

Commit

Permalink
midi_hooks should return void
Browse files Browse the repository at this point in the history
  • Loading branch information
marchingband committed Jan 4, 2022
1 parent 7b940bd commit e4beb11
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 17 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ Code for the WVR USB Backpack is here : https://github.com/marchingband/wvr_usb_
# powering wvr

* **wvr basic** : plug in usb, or apply 5v and ground, or 3.3v and ground, to the power pins
* **wvr makers board** : plug in usb (will not power amp), use a center-negative 9v PSU (boss style) or apply somewhere between 5v and 9v and ground to the VIN pins
* **wvr dev board** : plug in usb, use a center-negative 9v PSU (boss style) or apply somewhere between 5v and 9v and ground to the VIN pins
* **thames** : use a center-negative 9v PSU (boss style)
* **wvr makers board** : plug in usb (will not power amp), use a center-negative 9v PSU (Boss style) or apply somewhere between 6v and 9v (and ground) to the VIN pins
* **wvr dev board** : plug in usb, use a center-negative 9v PSU (Boss style) or apply somewhere between 6v and 9v and ground to the VIN pins
* **thames** : use a center-negative 9v PSU (Boss style)
* **usb host backpack** : The backpack is powered by the WVR, so if WVR is on, the backpack is also on. When updating firmware on the backpack, plug in the usb micro port on the backpack **instead of** powering the WVR. It has its 5v line connected to the WVR 5v pin. WVR takes this 5v line, passes it to the LDO, and passes 3.3v back to power the backpack. The 5v pin on the USB host port is also connected to the WVR 5v pin, so it can power whatever is plugged into it, adding some capacitance to meet the USB spec.

# updating firmware
Expand Down
7 changes: 6 additions & 1 deletion src/WVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ 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);
Expand All @@ -69,7 +74,7 @@ void WVR::unmute(void)
set_mute(false);
}

void WVR::setMidiHook(uint8_t*(*fn)(uint8_t *in))
void WVR::setMidiHook(void(*fn)(uint8_t *in))
{
set_midi_hook(fn);
}
Expand Down
6 changes: 2 additions & 4 deletions src/WVR.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,15 @@ class WVR {
void wifiOn(void);
void toggleWifi(void);
void setGlobalVolume(uint8_t volume);
uint8_t getGlobalVolume(void);
void mute(void);
void unmute(void);
void setMidiHook(uint8_t*(*fn)(uint8_t *in));
void setMidiHook(void(*fn)(uint8_t *in));
void encoderInit(int encA, int encB);
void onEncoder(void (*handleEncoder)(bool up));
void resetPin(int pin);
uint8_t getVoice(int channel);
void setVoice(int channel, int voice);
// int globalVolume;
// bool mute;
// bool autoConfigPins;
bool wifiIsOn;
bool useFTDI;
bool useUsbMidi;
Expand Down
5 changes: 5 additions & 0 deletions src/file_system.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ void set_global_volume(uint8_t vol)
metadata.global_volume = vol;
}

uint8_t get_global_volume(void)
{
return metadata.global_volume;
}

void write_metadata(struct metadata_t m){
struct metadata_t *buf = (struct metadata_t *)ps_malloc(SECTOR_SIZE * METADATA_SIZE_IN_BLOCKS);
buf[0] = m;
Expand Down
1 change: 1 addition & 0 deletions src/file_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ void current_bank_up(void);
void current_bank_down(void);
struct metadata_t *get_metadata(void);
void set_global_volume(uint8_t vol);
uint8_t get_global_volume(void);
void log_pin_config(void);
size_t getNumSectorsInEmmc(void);
void getSector(size_t i, uint8_t *buf);
Expand Down
2 changes: 1 addition & 1 deletion src/midi.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extern "C" {

uint8_t* midi_parse(uint8_t in);
uint8_t* usb_midi_parse(uint8_t in);
uint8_t* midi_hook_default(uint8_t *in);
void midi_hook_default(uint8_t *in);

#ifdef __cplusplus
}
Expand Down
12 changes: 6 additions & 6 deletions src/midi_in.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct wav_player_event_t wav_player_event;
uint8_t *msg;
uint8_t *usb_msg;

uint8_t*(*midi_hook)(uint8_t *in);
void(*midi_hook)(uint8_t *in);

void init_gpio()
{
Expand Down Expand Up @@ -126,7 +126,7 @@ static void read_uart_task()
if(msg)
{
// send it through the midi filter hook
msg = midi_hook(msg);
midi_hook(msg);
}
if(msg)
{
Expand Down Expand Up @@ -267,7 +267,7 @@ static void read_usb_uart_task()
if(usb_msg)
{
// send it through the midi filter hook
usb_msg = midi_hook(usb_msg);
midi_hook(usb_msg);
}
if(usb_msg)
{
Expand Down Expand Up @@ -398,12 +398,12 @@ void midi_init(bool useUsbMidi)
// xTaskCreatePinnedToCore(read_uart_task, "read_uart_task", 4096, NULL, 3, NULL, 1);
}

uint8_t* midi_hook_default(uint8_t* in)
void midi_hook_default(uint8_t* in)
{
return in;
return;
}

void set_midi_hook(uint8_t*(*fn)(uint8_t *in))
void set_midi_hook(void(*fn)(uint8_t *in))
{
midi_hook = fn;
}
4 changes: 2 additions & 2 deletions src/midi_in.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ struct midi_event_t {
};

uint8_t *get_channel_lut(void);
uint8_t* midi_hook_default(uint8_t* in);
void set_midi_hook(uint8_t*(*fn)(uint8_t *in));
void midi_hook_default(uint8_t* in);
void set_midi_hook(void(*fn)(uint8_t *in));

#ifdef __cplusplus
}
Expand Down

0 comments on commit e4beb11

Please sign in to comment.