DerSpanischGamer / ay-3-8910-midi

An interface from a PC through an Arduino to an AY-3-8910 / YM 2149
GNU General Public License v3.0
10 stars 2 forks source link

ay-3-8910-midi

An interface in Python and C for the AY-3-8910 (or YM2149) that uses an Arduino (or ATmega328-P)

To be able to send midi files, first they must be converted to .csv with this program : https://www.fourmilab.ch/webtools/midicsv/#Download

(or any other that transforms .mid to .csv)

File explanation

Folder AY3910RegWrite (original file for 1 chip connected to an Arduino)

As its name indicates, in this folder, there's the code to for just 1 IC connected to an Arduino. Conexiones.png

Folder https://github.com/DerSpanischGamer/ay-3-8910-midi/tree/master/AY3910RegWrite-library

Code that supports 2 chips simultaneously. Is simplified version of the preivous code and made easier to read thanks to the fact that it has been made into a library.

Folder Amadeus

Is the library that makes everything cleaner and easier to read.

The only functions to keep in mind are:

Import the library #include "Amadeus.h"

Create and instance of the library Amadeus amadeus = Amadeus(); // Init Amadeus clss

Start the clock and configure the pins amadeus.begin();

Write the value VAL to register REG of chip C amadeus.out(C, REG, VAL);

The rest of the functions are private as they are only used to carry out the functions described above. If you are curioused you can take a look at the code.

Folder Canciones

Not much to say. Stores some songs for which I have searched the .mid file adn I have transformed into .csv to be able to play them.

Folder Programas

Boy oh boy, is here where the fun begins. First, teh files .exe should be ignore (for the most part).

Alright, we are at the .py files that are interesting:

The way it stores data is the following:

'INFOS,BPM,CHIP

TIMESTAMP,VAL,VAL,VAL...

TIMESTAMP,VAL,VAL,VAL...

...'

where INFOS is a string that never changes, BPM is the BPM of the song and CHIP is the number of chips that are needed to play the song.

.amds only stores the timestamps where there's a change in any of the registers. That's why TIMESTAMP doesn't increment from 0 to the end of the file, but there are jumps. This means that the notes are held for all that time.

Use: python amadeusguardar.py "FILE.csv" "OUTPUT.amds"

Note: you can open .amds files with Notepad++, Libreoffice Calc or Excel.

To use: 'python amadeussender_legacy.py "FILE.csv" "PORT"'

IMPORTANT: the data sent by this program are in this order:

So, if we send the bytes [0x00, 0x01, 0x02] we will be writing the value 0x02 to the register 0x01 of the chip 0x00 (first).

To be able to make it work, we have to upload to the board the correct software.

How to use: 'python amadeussender.py "FILE.csv" "PORT" "VOLUME=15"'

The default volume is 15. You don't have to write VOLUME=, just the value between 0 and 15 (included) that you want the board to play. Recommendation: 10-12 is not very loud and not very faint.

frequency_calculator.py prints a string with the shape of a python array that then can be directly pasted in a script.

To use: 'python frequency_calculator.py [FREQUENCY IN Hz (OPTIONAL)]'

Ex.: 'python frequency_calculator.py' or 'python frequency_calculator.py'

=> The first executes the program for the default frequency of 2MHz, meanwhile the 2nd will execute the program for a frequency of 1MHz.

Folder VideoMaker (dentro de la carpeta Programas)

Contains the program cancionVideo.py. This program is out of date because it uses the old .amds format.

It takes a .amds file and transforms it into a series of frames that then can be made into a video using the program ffmpeg. I leave the command to be used in the file comando.txt

CREDITS: