Giter VIP home page Giter VIP logo

Comments (4)

ladyada avatar ladyada commented on July 25, 2024

that demo is for use with feathers only

from adafruit_vs1053_library.

snaxxus avatar snaxxus commented on July 25, 2024

//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.

ladyada avatar ladyada commented on July 25, 2024

woops, can you submit a PR? it would be really helpful!

from adafruit_vs1053_library.

snaxxus avatar snaxxus commented on July 25, 2024

//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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.