Comments (4)
that demo is for use with feathers only
from adafruit_vs1053_library.
//pst... pst...
//these flags aren't defined
//Select one of those defines and adapt it to your board. FYI this dontn't work on the FeatherM0, so I copies #define VS1053_MIDI Serial1 out of the #if block and bwooping ensues.
#if defined(AVR_ATmega32U4) || defined(ARDUINO_SAMD_FEATHER_M0) || defined(TEENSYDUINO) || defined(ARDUINO_STM32_FEATHER)
#define VS1053_MIDI Serial1
#elif defined(ESP32)
HardwareSerial Serial1(2);
#define VS1053_MIDI Serial1
#elif defined(ESP8266)
#define VS1053_MIDI Serial
#endif
from adafruit_vs1053_library.
woops, can you submit a PR? it would be really helpful!
from adafruit_vs1053_library.
//Edit: I'm using the Feather M0 basic
//Windows 7 32 bit on old work laptop
//Running arduino IDE 1.8.6
//In boards manager added Arduino SAMD boards (32-bits ARM Cortex-M0+) By Arduino version 1.6.19
//^^^^^ It was required
//In boards manager added Adafruit SAMD boards by Adafruit version 1.2.3
//^^^^^ of course we need it (compiles normal examples but complains because the driver disconnects and comes up on a different com port. This is not directly the problem)
//Downloaded Adafruit_VS1053_Library-master.zip and installed it with Manage Libraries in Arduino IDE
//would get vvvvvv
//exit status 1
//'VS1053_MIDI' was not declared in this scope
//until I pulled #define VS1053_MIDI Serial1 out of the #if block below
// I suspect the ARDUINO_SAMD_FEATHER_M0 flag is not defined or another flag should be included in the #if block
#include <Adafruit_VS1053.h>
// Solder closed jumper on bottom!
// See http://www.vlsi.fi/fileadmin/datasheets/vs1053.pdf Pg 31
#define VS1053_BANK_DEFAULT 0x00
#define VS1053_BANK_DRUMS1 0x78
#define VS1053_BANK_DRUMS2 0x7F
#define VS1053_BANK_MELODY 0x79
// See http://www.vlsi.fi/fileadmin/datasheets/vs1053.pdf Pg 32 for more!
#define VS1053_GM1_OCARINA 80
#define MIDI_NOTE_ON 0x90
#define MIDI_NOTE_OFF 0x80
#define MIDI_CHAN_MSG 0xB0
#define MIDI_CHAN_BANK 0x00
#define MIDI_CHAN_VOLUME 0x07
#define MIDI_CHAN_PROGRAM 0xC0
//QnD Fix vvvv***
#define VS1053_MIDI Serial1
//QnD Fix ^^^^***
#if defined(AVR_ATmega32U4) || defined(ARDUINO_SAMD_FEATHER_M0) || defined(TEENSYDUINO) || defined(ARDUINO_STM32_FEATHER)
#define VS1053_MIDI Serial1
#elif defined(ESP32)
HardwareSerial Serial1(2);
#define VS1053_MIDI Serial1
#elif defined(ESP8266)
#define VS1053_MIDI Serial
#endif
void setup() {
delay(1000);
Serial.begin(115200);
Serial.println("VS1053 MIDI test");
VS1053_MIDI.begin(31250); // MIDI uses a 'strange baud rate'
midiSetChannelBank(0, VS1053_BANK_MELODY);
midiSetChannelVolume(0, 127);
midiSetInstrument(0, VS1053_GM1_OCARINA);
}
void loop() {
for (uint8_t i=60; i<69; i++) {
midiNoteOn(0, i, 127);
delay(100);
midiNoteOff(0, i, 127);
}
delay(1000);
}
void midiSetInstrument(uint8_t chan, uint8_t inst) {
if (chan > 15) return;
inst --; // page 32 has instruments starting with 1 not 0 :(
if (inst > 127) return;
VS1053_MIDI.write(MIDI_CHAN_PROGRAM | chan);
delay(10);
VS1053_MIDI.write(inst);
delay(10);
}
void midiSetChannelVolume(uint8_t chan, uint8_t vol) {
if (chan > 15) return;
if (vol > 127) return;
VS1053_MIDI.write(MIDI_CHAN_MSG | chan);
VS1053_MIDI.write(MIDI_CHAN_VOLUME);
VS1053_MIDI.write(vol);
}
void midiSetChannelBank(uint8_t chan, uint8_t bank) {
if (chan > 15) return;
if (bank > 127) return;
VS1053_MIDI.write(MIDI_CHAN_MSG | chan);
VS1053_MIDI.write((uint8_t)MIDI_CHAN_BANK);
VS1053_MIDI.write(bank);
}
void midiNoteOn(uint8_t chan, uint8_t n, uint8_t vel) {
if (chan > 15) return;
if (n > 127) return;
if (vel > 127) return;
VS1053_MIDI.write(MIDI_NOTE_ON | chan);
VS1053_MIDI.write(n);
VS1053_MIDI.write(vel);
}
void midiNoteOff(uint8_t chan, uint8_t n, uint8_t vel) {
if (chan > 15) return;
if (n > 127) return;
if (vel > 127) return;
VS1053_MIDI.write(MIDI_NOTE_OFF | chan);
VS1053_MIDI.write(n);
VS1053_MIDI.write(vel);
}
from adafruit_vs1053_library.
Related Issues (20)
- Millis() function is extremely inaccurate when playing audio on Feather M0 HOT 2
- "Adafruit_VS1053.cpp" problem with "feather_player" exemple HOT 2
- record_ogg example does not support multiple recordings without reset HOT 2
- setVolume ranges? HOT 1
- Travis Build Broken HOT 1
- Error in compilation for Arduino Uno WiFi Rev2 HOT 2
- Compiler error when using a Arduino Nano Every (ATMega4809) HOT 4
- Problem with begin() HOT 1
- how to use the applyPatch() function? HOT 4
- Not really a issue but.. HOT 7
- custom SPI pins not working on ESP32 HOT 29
- Convert to BusIO HOT 1
- Strange error occurs once and again while using Music Maker
- Increase SPI clock? HOT 1
- Please fix sdfat HOT 4
- Does not work on ESP32 HOT 7
- Using SDfat on RP2040 (earlephilhower core) HOT 1
- Issue with Ogg Recording Example on VS1053 Breakout Board
- Playback stops (but not fully) when changing volume too quickly
- Possible Code Modifications for Adafruit_VS1053 Files
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from adafruit_vs1053_library.