sid_library
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
sid_library [2011/09/27 10:59] – wadmin | sid_library [2018/08/26 09:36] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | This library | + | ===== SID Library ===== |
+ | The library | ||
+ | Connecting | ||
+ | Schematic, Layout and Source Code of the associated Midi Synth project SIDaster can be found here : http:// | ||
+ | |||
+ | ==== Download ==== | ||
+ | |||
+ | Download Link : {{: | ||
==== Installation ==== | ==== Installation ==== | ||
+ | |||
+ | As simple as an Arduino library installation: | ||
* Go to your '' | * Go to your '' | ||
Line 25: | Line 35: | ||
==== Code example ==== | ==== Code example ==== | ||
- | here is an example of how to use the library: | + | Here is an example of how to use the library, showing how to combine the '' |
+ | |||
+ | < | ||
+ | |||
+ | <code C> | ||
+ | #include < | ||
+ | #include < | ||
+ | |||
+ | // Pulse width must be less than 0x0FFF (4095) | ||
+ | // note - must also be higher than nothing if using a square wave | ||
+ | // | ||
+ | #define PULSE_WIDTH 0x0 | ||
+ | |||
+ | // These all must be below 0x0F (15) | ||
+ | |||
+ | // | ||
+ | // GLOBAL SYNTH VARIABLES INIT | ||
+ | // | ||
+ | |||
+ | SID sid; | ||
+ | |||
+ | // Play sound at frequency specified on voice specified | ||
+ | // | ||
+ | void synth_on(int note) | ||
+ | { | ||
+ | freq1=NOTES[note]; | ||
+ | sid.send(SID_FREQ1LO, | ||
+ | sid.send(SID_FREQ1HI, | ||
+ | freq2=NOTES[note+3]; | ||
+ | sid.send(SID_FREQ2LO, | ||
+ | sid.send(SID_FREQ2HI, | ||
+ | freq3=NOTES[note+7]; | ||
+ | sid.send(SID_FREQ3LO, | ||
+ | sid.send(SID_FREQ3HI, | ||
+ | ctrl1|=1; | ||
+ | sid.send(SID_CTRL1, | ||
+ | ctrl2|=1; | ||
+ | sid.send(SID_CTRL2, | ||
+ | ctrl3|=1; | ||
+ | sid.send(SID_CTRL3, | ||
+ | } | ||
+ | |||
+ | void synth_off(int note) | ||
+ | { | ||
+ | ctrl1& | ||
+ | sid.send(SID_CTRL1, | ||
+ | ctrl2& | ||
+ | sid.send(SID_CTRL2, | ||
+ | ctrl3& | ||
+ | sid.send(SID_CTRL3, | ||
+ | } | ||
+ | |||
+ | // Debug 2 bytes of data via the address + data shifters | ||
+ | // | ||
+ | |||
+ | // Initially executed code | ||
+ | // | ||
+ | void setup() | ||
+ | { | ||
+ | // Set up the SID chip | ||
+ | sid.clk_setup(); | ||
+ | sid.SPI_setup(); | ||
+ | |||
+ | // Give the voices some initial values | ||
+ | // Set up the MIDI input | ||
+ | MIDI.begin(); | ||
+ | MIDI.setHandleNoteOn(DoHandleNoteOn); | ||
+ | MIDI.setHandleNoteOff(DoHandleNoteOff); | ||
+ | |||
+ | synth_init(); | ||
+ | |||
+ | } | ||
+ | |||
+ | // Main program loop | ||
+ | // | ||
+ | void loop() { | ||
+ | MIDI.read(); | ||
+ | } | ||
+ | |||
+ | // Note On Handler | ||
+ | // PS : The if / else is implemented because some Midi equipements do not use Note Off, but use instead note On with velocity = 0 | ||
+ | void DoHandleNoteOn (byte channel, byte note, byte velocity) { | ||
+ | | ||
+ | } | ||
+ | void DoHandleNoteOff (byte channel, byte note, byte velocity) { | ||
+ | synth_off(note); | ||
+ | } | ||
+ | </ | ||
+ | ==== Changelog ==== | ||
+ | See the SID.h file comments for library changelog. |
sid_library.1317121199.txt.gz · Last modified: 2018/08/26 09:36 (external edit)