CodeWalrus

Development => Hardware => Topic started by: garvalf on July 03, 2016, 12:50:24 PM

Title: SID + midi on Arduino and YM2149 emulator on atmega8
Post by: garvalf on July 03, 2016, 12:50:24 PM
As said in this thread (https://codewalr.us/index.php?topic=1397.msg40508#msg40508), I'm working a SID sound chip simulator on Arduino. I'm not responsible for most of the code, but I've assembled some parts, a SID emulator, a midi library, and some settings for modifing the chip.


Here is a better sample:

https://soundcloud.com/memento-somniare/sidarduino-test

The last part has some kind of hard bass sound (sawtooth).

and the code (w.i.p.):

https://github.com/farvardin/C64-music/tree/master/sid_arduino/sid_midi

Now I want to make it polyphonic and be able to adjust correctly the filters (if it's possible/implemented) so it will sound more like SID chip...

The same setup can play sid file using a different arduino sketch: https://github.com/farvardin/C64-music/tree/master/sid_arduino/sid_player
But because of the memory limitation, it can't play a whole tune. It should be adapted to be able to read from an sd card.

Title: Re: SID + midi on Arduino
Post by: Yuki on July 03, 2016, 06:32:09 PM
Ah nice. I did that the other day, I had something that recognized the serial port as a MIDI device, so I could use any DAW that supports it and send some MIDI signals, so I could play full songs, but the SID is only limited to 3 channels at a time... Still sounds good. Could probably upload the sketch I have, if that helps.
Title: Re: SID + midi on Arduino
Post by: Dream of Omnimaga on July 04, 2016, 04:36:12 AM
Cool project Garvalf, and I just listened to the track and it sounds cool. :D
Title: Re: SID + midi on Arduino
Post by: garvalf on July 04, 2016, 11:48:16 AM
Yes, i'd like to see your code Juju
Title: Re: SID + midi on Arduino
Post by: DarkestEx on September 05, 2016, 04:19:00 PM
@Juju @garvalf
What is the license on your project(s)?
We are working on a game console and we want to use an emulated C64 SID synthesizer for the optional audio.
Would you be interested in helping us. We would like to make it an external module. And yes, we would make an actual PCB for this.
The communication between the main CPU and the SID would be SPI. The sound-CPU could be an ATmega328p @ 8 MHz.
Title: Re: SID + midi on Arduino
Post by: garvalf on September 05, 2016, 04:40:23 PM
@DarkestEx : cool idea! 99% of the code I'm using is not mine, and it seems it's GPLv2 (look at the headers), so you can use it under this licence. I'm still curious to look at @Juju 's one, which is probably more advanced!
Will you use 2 arduinos for this project, or something else?
Title: Re: SID + midi on Arduino
Post by: DarkestEx on September 05, 2016, 04:45:21 PM
Quote from: garvalf on September 05, 2016, 04:40:23 PM
@DarkestEx : cool idea! 99% of the code I'm using is not mine, and it seems it's GPLv2 (look at the headers), so you can use it under this licence. I'm still curious to look at @Juju 's one, which is probably more advanced!
Will you use 2 arduinos for this project, or something else?
Oh dammit :(
No GPL code is permitted in our main project, but luckily the Audio is a separate add-on, so this will work fine :)
The external add-on SID processor will be using an Arduino-compatible CPU, but the main CPU (while it theoretically could run Arduino) won't.
It's a 32-bit Tensilica CPU running at 160 MHz. The system also has WiFi, a USB interface and a SD card slot for loading the UI, games and programs from.
Here is an image of the prototype PCB I am working on:
[spoiler=Prototype](http://i.imgur.com/lQ21Vlq.jpg)[/spoiler]
The system called Microcat will be running my own Claw operating system (which is BSD licensed and therefore incompatible). It can be programmed in my custom assembly language or in Cumred_Snektrons high level compiler for it. The operating system supports multitasking.

EDIT:
I think we will integrate Audio into the main board anyways. It's quite mean to have a console that can't even beep.
So here we go:
(http://www.3bm.de/wp-content/uploads/2013/09/ATtiny84_arduino-tiny_pins.png)
We will integrate audio into this little puppy ^, an ATtiny84.
The SPI will be used for communication, one pin will be Chip Select. The reset pin is routed to the main CPU as well to allow updating it's firmware.
Most of the other pins will be used for generating polyphonic sound.
Title: Re: SID + midi on Arduino
Post by: Yuki on September 05, 2016, 05:33:29 PM
I remember I took a SID emulation library and a MIDI over serial library and I just stitched them together, I didn't wrote a lot of lines of code and I have no idea if it's GPL. I'll look at this tonight and send the source. The libraries I used are likely somewhere on GitHub.
Title: Re: SID + midi on Arduino
Post by: Dream of Omnimaga on September 20, 2016, 08:29:23 PM
I would definitively like C64 SID emulation in Microcat :)
Title: Re: SID + midi on Arduino
Post by: garvalf on September 22, 2016, 08:30:41 AM
It's cool if you use an external (arduino) chip for making the music! It can maybe be complicated to make it communicate with the main CPU, can't it?
The arduino sketch can replay some psid files quite accurately, but the psid has to be converted to special data and embeded as .h file from the arduino ide, like this: https://github.com/farvardin/C64-music/blob/master/sid_arduino/sid_player/Alternative_Fuel_dmp.h
And because of the arduino memory, you can't add much music (around 10-15 seconds). But it should be possible to stream the data from sd card or other storage (the only examples I can find are from a read SID, not with the arduino emulator)

There are also other projects using for example the ym2149 chip (AY), for example this one: http://www.avray.ru/
You can use arduino sketches with it for playing Sinclair Spectrum or Atari St music. Look at this: http://www.avray.ru/playing-yrg-rsf-files-from-sd-card-with-emulator/comment-page-1/#comment-205
It could be cool to integrate into your console project.

I've worked a bit more on the Sid emulator. It can handle multi voices (3 like original SID, but it should be also possible to create more register and add more voices), the only problem is on midi I can't separate the voice, i.e. play a voice on channel 1, play another voice (sound) on channel 2 etc, I can mix the voices together but I have to select the midi channel. I've tried to modify the midi part but it's beyond my knowledge, for example I'm using some code which should theorically work, but don't practically (http://arduinomidilib.fortyseveneffects.com/a00025.html#ga4c50a2be0160dfb169126c7d9e6d1458)

I've discovered the "arduino pro mini" are even smaller than arduino nano. You can find some clones for a very cheap price (around 2 €). You only need a programmer / usb interface because they don't have this, so it's not practical for designing, it's more for final stuff. Fun fact: it has almost the same size as a real SID chip.

I'm attaching a picture of the whole family, from left to right: the ftdi programmer, the arduino pro mini, the arduino nano.
Title: Re: SID + midi on Arduino
Post by: garvalf on September 28, 2016, 07:39:01 PM
I've managed to make the AY emulator from http://www.avray.ru/ work, it sounds really great! I still need to adjust a few things, and I'd like to program it for using midi, if it's possible. I'll post a little video in a few days or weeks.
Title: Re: SID + midi on Arduino
Post by: Dream of Omnimaga on September 29, 2016, 04:30:04 PM
Awesome :D. I can't wait to see it in action Garvalf :)
Title: Re: SID + midi on Arduino
Post by: garvalf on October 13, 2016, 08:41:48 PM
It's quite short and not very well recorded, but here is the avr-ay emulator in action:
https://www.youtube.com/watch?v=zdgwH8YQm4k

Title: Re: SID + midi on Arduino
Post by: Dream of Omnimaga on November 03, 2016, 05:55:30 PM
That is awesome and old-school. Glad to see it working :)

:walrii:
Title: Re: SID + midi on Arduino and YM2149 emulator on atmega8
Post by: garvalf on November 04, 2016, 09:20:05 PM
Thank you.

I've finally soldered a cleaner version on a board last week-end. Damn it was long. There is almost nothing on the board, but under it there are quite many wires. I've put the atmega8 chip under the arduino nano. I'd like to make a PCB for making more boards like this.

Here is a new video with my new toy:
http://www.youtube.com/watch?v=gzpGbokxwZ4

and a picture of the board:

(https://lut.im/RExgly27x1/ufHqmhwLH6MOIwJk.jpg)

So there is a sd card reader connected to the arduino which read the data, then pass it to the atmega8 which is the sound chip recreating the ym2148.
Title: Re: SID + midi on Arduino and YM2149 emulator on atmega8
Post by: Dream of Omnimaga on January 27, 2017, 05:44:09 AM
I'M very late, but nice video @garvalf . Thanks for sharing. :)

Have you done any updates to this or new songs, by the way?
Title: Re: SID + midi on Arduino and YM2149 emulator on atmega8
Post by: garvalf on January 27, 2017, 02:34:03 PM
I've worked more on the AY shield, but I didn't manage to draw a correct PCB. I think I'll ask a friend for help, he can do this kind of thing. Then I'll start mass production (between 10 and 15 pieces  ;D ).

No new AY music, but I've made a few for the Megadrive / Genesis chips (FM and PSG). I like using this platform because it's easy to compose tunes with DefleMask, and the Everdrive MD makes it quick to replay from the Megadrive console (using a SD card). I'll post something in my music section.

Title: Re: SID + midi on Arduino and YM2149 emulator on atmega8
Post by: Dream of Omnimaga on February 05, 2017, 07:57:55 PM
Mass production means you're gonna sell some of those, right? :3
Title: Re: SID + midi on Arduino and YM2149 emulator on atmega8
Post by: p3n4 on February 05, 2017, 11:21:01 PM
That sounds like a nice Project :D
Title: Re: SID + midi on Arduino and YM2149 emulator on atmega8
Post by: novenary on February 06, 2017, 07:30:12 AM
Oh wow, I must have missed this. I remember @Keoni29 made something similar and built it into his 84+ way back in 2012-13. That was a pretty good idea actually, since it frees the CPU to run an actual game together with audio.
Pretty much like old consoles did. Nowadays the DSP functions are integrated into the CPU itself with SIMD instructions, but that wasn't an option and even early 2000's consoles used a dedicated DSP for mixing and playback.
Title: Re: SID + midi on Arduino and YM2149 emulator on atmega8
Post by: garvalf on February 12, 2017, 11:14:12 PM
Quote from: DJ Omnimaga on February 05, 2017, 07:57:55 PM
Mass production means you're gonna sell some of those, right? :3

yes, of course I plan to sell this thing, either the PCB alone, or as a kit with all the parts.

Now for something completely different (but still related to Arduino):

Shiru from the 1-bit forum has released a port of his Octode 1-bit engine to the Arduino plateform. It was originally written in z80 ASM, and it was rewritten in C / Arduino code. It's not exactly the same, but still pretty good. Here is a quick recording I made (of a rather strange tune I must say):
http://garvalf.online.fr/index.php?page=blog_2017-02-12

It's very easy to set up, just upload  in the Arduino IDE the sketch in attachment from the first post there http://randomflux.info/1bit/viewtopic.php?pid=1147 , connect pin 7 and ground to a speaker, and you'll get 1-bit music!
Title: Re: SID + midi on Arduino and YM2149 emulator on atmega8
Post by: garvalf on August 04, 2017, 12:02:27 PM
well, it was long, but I managed to draw to PCB. My friend didn't do it for me, instead he helped me much with advices and corrections. I've used Fritzing, and now I understand better how it works.

The PCB is almost ready for production, I'll send it very soon. It will feature:

- AY-3-8910 emulator (on atmega8), driven by the arduino nano.
- It can replay sinclair, atari, amstrad chiptunes from the sd card
- it might be possible to use it as a (very simple and dirty) AY synth! The avray creator helped me for this, for sending simple notes, I just need to code the synth now, I'll reuse parts from the sid synth)

- Sid emulator (on arduino)
- it can replay some sid files, from the arduino memory, which is limited (so tunes will be cut). I'd like to find a way to stream the tune from the sd card, it's probably possible
- it can be used as a Sid synth (see previous messages)

- 1 bit music player (on arduino)
- it can get music from the arduino memory. 1 bit music don't need much memory so this time a whole song, even a complex one, can fit in the memory. It might be possible to stream data from SD if the 1-bit music engine chosen is the same for all the songs.
- it should be possible to create a 1-bit synth, but I don't know why. Probably not an easy task.

- Mozzy synth (see https://sensorium.github.io/Mozzi/ ), which can output fun FM sounds and many other effects.

There will be also room for adding light sensors and use the whole thing as a noise box...

I'll also post the PCB sources (if it works as expected)
Title: Re: SID + midi on Arduino and YM2149 emulator on atmega8
Post by: garvalf on August 24, 2017, 08:33:29 AM
I've ordered the PCB. I've made a little error on it which I noticed too late, but it shouldn't be a big problem and could be fixed. I hope there are not more :)

Some more sound examples:

- http://picosong.com/HUGM/ (Xenon / Spectrum)
- http://picosong.com/wseMn/ (Cauldron / Amstrad)
- https://soundcloud.com/memento-somniare/sidarduino-test (C64 SID synth)
- http://battleofthebits.org/arena/Entry/Underground+Water/26509/ (personal creation, for zx spectrum)

In addition this board has:

- a low pass filter
- arduino nano
- SD card reader
- Midi DIN-5 connector

I'll sell the PCB card alone (if it works as expected), for a cheap price like 3 or 4 € without shipping , and also some complete kits and assembled product (should be below 20 € without shipping)

The github project:
https://github.com/farvardin/garvuino

A picture of the PCB:
(https://lut.im/UDH644T7KJ/HSxfYwtAfpHTcHMp.jpg)

Title: Re: SID + midi on Arduino and YM2149 emulator on atmega8
Post by: Dream of Omnimaga on August 26, 2017, 04:08:53 PM
Nice to see this is alive and well @garvalf . I will listen to to the songs you made and posted when I get some free time again.
Title: Re: SID + midi on Arduino and YM2149 emulator on atmega8
Post by: garvalf on October 14, 2017, 12:36:27 PM
I've made a little video to present the board:

https://www.youtube.com/watch?v=npYsu0WO_XI