* WalrusIRC

You need to have 5 posts and not be part of restricted usergroups in order to use the WalrusIRC embedded shoutbox. However, you can also access our IRC channel called #CodeWalrus via EFnet.

Author Topic: SID + midi on Arduino and YM2149 emulator on atmega8  (Read 4062 times)

0 Members and 1 Guest are viewing this topic.

Offline garvalf

  • Full User
  • Join Date: Oct 2015
  • Location:
  • Posts: 105
  • Post Rating Ratio: +1/-0
    • Garvalf's lair
  • Gender: Male
SID + midi on Arduino and YM2149 emulator on atmega8
« on: July 03, 2016, 12:50:24 pm »
As said in this thread, 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.

« Last Edit: November 04, 2016, 09:15:51 pm by garvalf »


  • Calculators owned: TI-83+ fr, TI-82

Online Juju

  • aka Yuki Kagayaki aka J̵̭͕͇ù̞̭̝̯̦j̴̭̙̗͖͡ù͏͓̲̕
  • CodeWalrus Staff
  • Super User
  • Server Maintenance
  • Moderator
  • Forum Maintenance
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Inside a walrus
  • Posts: 2963
  • Post Rating Ratio: +27/-2
  • Couch potato
    • jul.savard
    • juju2143
    • @juju2143
    • juju2143
    • @julosoft
    • juju-kun
    • /u/juju2143
    • juju2143
    • Juju's shed
  • Gender: Female
  • WalriiPoints: 99999
Re: SID + midi on Arduino
« Reply #1 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.
  • Calculators owned: TI-83+ (dead?), Casio Prizm (also dead???)
YUKI-CHAAAANNNN
In the beginning there was walrii. In the end there will be walrii. All hail our supreme leader :walrii: --Snektron


if you wanna throw money at me and/or CodeWalrus monthly it's here

Offline xlibman

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18522
  • Post Rating Ratio: +95/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: SID + midi on Arduino
« Reply #2 on: July 04, 2016, 04:36:12 am »
Cool project Garvalf, and I just listened to the track and it sounds cool. :D
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline garvalf

  • Full User
  • Join Date: Oct 2015
  • Location:
  • Posts: 105
  • Post Rating Ratio: +1/-0
    • Garvalf's lair
  • Gender: Male
Re: SID + midi on Arduino
« Reply #3 on: July 04, 2016, 11:48:16 am »
Yes, i'd like to see your code Juju
  • Calculators owned: TI-83+ fr, TI-82

Offline DarkestEx

  • Super User
  • Join Date: Jan 2015
  • Location: Germany
  • Posts: 1323
  • Post Rating Ratio: +10/-2
    • @0xbmuessig
    • @muessigb
    • My homepage
  • Gender: Male
Re: SID + midi on Arduino
« Reply #4 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.
  • Calculators owned: TI-84+, Casio 101-S, RPN-Calc, Hewlett-Packard 100LX, Hewlett-Packard 95LX
  • Consoles, mobile devices and vintage computers owned: Hewlett-Packard 100LX, Hewlett-Packard 95LX, Original Commodore 64C, Tektronix AWG2021, IBM X60s, IBM X60t, Nintendo DS Lite, Nintendo GameBoy Color, Nintendo GameCube, Xbox 360, Palm m5


Avatar drewn for me by Tabbes.

Offline garvalf

  • Full User
  • Join Date: Oct 2015
  • Location:
  • Posts: 105
  • Post Rating Ratio: +1/-0
    • Garvalf's lair
  • Gender: Male
Re: SID + midi on Arduino
« Reply #5 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?
  • Calculators owned: TI-83+ fr, TI-82

Offline DarkestEx

  • Super User
  • Join Date: Jan 2015
  • Location: Germany
  • Posts: 1323
  • Post Rating Ratio: +10/-2
    • @0xbmuessig
    • @muessigb
    • My homepage
  • Gender: Male
Re: SID + midi on Arduino
« Reply #6 on: September 05, 2016, 04:45:21 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:
(click to show/hide)
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:

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.
« Last Edit: September 05, 2016, 05:19:22 pm by DarkestEx »
  • Calculators owned: TI-84+, Casio 101-S, RPN-Calc, Hewlett-Packard 100LX, Hewlett-Packard 95LX
  • Consoles, mobile devices and vintage computers owned: Hewlett-Packard 100LX, Hewlett-Packard 95LX, Original Commodore 64C, Tektronix AWG2021, IBM X60s, IBM X60t, Nintendo DS Lite, Nintendo GameBoy Color, Nintendo GameCube, Xbox 360, Palm m5


Avatar drewn for me by Tabbes.

Online Juju

  • aka Yuki Kagayaki aka J̵̭͕͇ù̞̭̝̯̦j̴̭̙̗͖͡ù͏͓̲̕
  • CodeWalrus Staff
  • Super User
  • Server Maintenance
  • Moderator
  • Forum Maintenance
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Inside a walrus
  • Posts: 2963
  • Post Rating Ratio: +27/-2
  • Couch potato
    • jul.savard
    • juju2143
    • @juju2143
    • juju2143
    • @julosoft
    • juju-kun
    • /u/juju2143
    • juju2143
    • Juju's shed
  • Gender: Female
  • WalriiPoints: 99999
Re: SID + midi on Arduino
« Reply #7 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.
  • Calculators owned: TI-83+ (dead?), Casio Prizm (also dead???)
YUKI-CHAAAANNNN
In the beginning there was walrii. In the end there will be walrii. All hail our supreme leader :walrii: --Snektron


if you wanna throw money at me and/or CodeWalrus monthly it's here

Offline xlibman

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18522
  • Post Rating Ratio: +95/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: SID + midi on Arduino
« Reply #8 on: September 20, 2016, 08:29:23 pm »
I would definitively like C64 SID emulation in Microcat :)
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline garvalf

  • Full User
  • Join Date: Oct 2015
  • Location:
  • Posts: 105
  • Post Rating Ratio: +1/-0
    • Garvalf's lair
  • Gender: Male
Re: SID + midi on Arduino
« Reply #9 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.
« Last Edit: September 22, 2016, 10:24:22 pm by garvalf »
  • Calculators owned: TI-83+ fr, TI-82

Offline garvalf

  • Full User
  • Join Date: Oct 2015
  • Location:
  • Posts: 105
  • Post Rating Ratio: +1/-0
    • Garvalf's lair
  • Gender: Male
Re: SID + midi on Arduino
« Reply #10 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.
  • Calculators owned: TI-83+ fr, TI-82

Offline xlibman

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18522
  • Post Rating Ratio: +95/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: SID + midi on Arduino
« Reply #11 on: September 29, 2016, 04:30:04 pm »
Awesome :D. I can't wait to see it in action Garvalf :)
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline garvalf

  • Full User
  • Join Date: Oct 2015
  • Location:
  • Posts: 105
  • Post Rating Ratio: +1/-0
    • Garvalf's lair
  • Gender: Male
Re: SID + midi on Arduino
« Reply #12 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:


  • Calculators owned: TI-83+ fr, TI-82

Offline xlibman

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18522
  • Post Rating Ratio: +95/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: SID + midi on Arduino
« Reply #13 on: November 03, 2016, 05:55:30 pm »
That is awesome and old-school. Glad to see it working :)

:walrii:
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline garvalf

  • Full User
  • Join Date: Oct 2015
  • Location:
  • Posts: 105
  • Post Rating Ratio: +1/-0
    • Garvalf's lair
  • Gender: Male
Re: SID + midi on Arduino and YM2149 emulator on atmega8
« Reply #14 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:


and a picture of the board:



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.
« Last Edit: November 04, 2016, 09:25:21 pm by garvalf »
  • Calculators owned: TI-83+ fr, TI-82

 


You can also use the following HTML or bulletin board code to share it on your page or forum signature!


Also do not forget to check our affiliates below.
Planet Casio TI-Planet Calc.news BroniesQC BosaikNet Velocity Games