Author Topic: TI84+ soundchip - arduino SID emulator  (Read 40695 times)

0 Members and 2 Guests are viewing this topic.

Offline Spenceboy98

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 547
  • Rating: +59/-2
    • View Profile
Re: TI84+ soundchip - arduino SID emulator
« Reply #30 on: January 16, 2013, 06:09:29 pm »
This is a great project. Keep up the good work! :)
I like milk.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: TI84+ soundchip - arduino SID emulator
« Reply #31 on: January 16, 2013, 07:03:21 pm »
This is very cool. :D

Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: TI84+ soundchip - arduino SID emulator
« Reply #32 on: January 18, 2013, 09:50:14 am »
I am tweaking the link protocol. Now I get speeds up to 380B/sec on normal.
If you like my work: why not give me an internet?








Offline SpiroH

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 729
  • Rating: +153/-23
    • View Profile
Re: TI84+ soundchip - arduino SID emulator
« Reply #33 on: January 18, 2013, 10:25:17 am »
That's already good enough, considering most of the music work is done in paralell by the SID slave.
Imho, you should also speed up the "pcb + enclosure" business to 'sell' it faster.
More: http://playground.arduino.cc/Main/SID-emulator

Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: TI84+ soundchip - arduino SID emulator
« Reply #34 on: January 18, 2013, 10:27:22 am »
Imho, you should also speed up the "pcb + enclosure" business to 'sell' it faster.
More: http://playground.arduino.cc/Main/SID-emulator

What do you mean by that?
If you like my work: why not give me an internet?








Offline SpiroH

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 729
  • Rating: +153/-23
    • View Profile
Re: TI84+ soundchip - arduino SID emulator
« Reply #35 on: January 18, 2013, 10:29:59 am »
Imho, you should also speed up the "pcb + enclosure" business to 'sell' it faster.
What do you mean by that?
i simply mean, the project final stages are always the hardest part to accomplish. that's all. :D

Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: TI84+ soundchip - arduino SID emulator
« Reply #36 on: January 18, 2013, 10:37:52 am »
I'm not going to rush this.
If you like my work: why not give me an internet?








Offline SpiroH

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 729
  • Rating: +153/-23
    • View Profile
Re: TI84+ soundchip - arduino SID emulator
« Reply #37 on: January 18, 2013, 10:40:02 am »
fair enough. i can understand it. no problem. but please do not not put it aside 'cos it's really good, you should now that.

Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: TI84+ soundchip - arduino SID emulator
« Reply #38 on: January 18, 2013, 10:42:08 am »
Wow that doesn't mean that I will not be working on this an awful lot :P I'm just taking my time to do lots of optimization :D When I say I'm not gonna rush a full release it definitely doesn't mean I will put it aside :P

Edit: Like for smilies instead of dots 8)
« Last Edit: January 18, 2013, 10:42:47 am by Keoni29 »
If you like my work: why not give me an internet?








Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: TI84+ soundchip - arduino SID emulator
« Reply #39 on: January 18, 2013, 12:47:38 pm »
I tried to optimize the arduino code, but it's not getting an awful lot faster since my first optimization.
Code: [Select]
#include <SID.h>

// MACROs
#define PIN2H (PIND & 0B00000100)
#define PIN3L !(PIND & 0B00001000)
#define CLR(x,y) (x&=(~(1<<y)))
#define SET(x,y) (x|=(1<<y))

SID mySid;

void setup()
{
  pinMode(2,INPUT);
  pinMode(3,INPUT);
  mySid.begin();
}

byte n=0;
int timer=0;
byte count=0;
byte get=B00000000;
int addrval[2] = {0};

void loop()
{
  do{
    do
    {
      if (PIN3L)          // If the clock pin is LOW
      {
        if (PIN2H)        // And the data pin is HIGH
        {
          CLR(get,count); // CLEAR BIT
        }
        else              // otherwise
        {
          SET(get,count); // SET BIT
        }
        count++;          // Increase the bit counter
       
        while(PIN3L)      // Wait until the clock pin goes HIGH again
        {
        timer++;          // Increase the timeout timer
          if (timer==500){// Timeout at 500 loops
            n=count=0;    // Reset counters
            break;        // Break free
          }
        }
        timer=0;          // Reset the timeout timer
      }
    }while(count!=8);     // Loop again when the bit counter has not reached 8 bits yet
    addrval[n]=get;       // Otherwise store the received byte in an array in cell n
    n++;                  // Increase the byte counter
    count=0;              // Reset the bit counter
  }while(n!=2);           // Loop again when the byte counter has not reached two bytes yet
                          // Otherwise write the value to the register.
  mySid.set_register(addrval[0], addrval[1]);
  n=0;                    // Reset the byte counter
}
Can someone tell me what to optimize?
If you like my work: why not give me an internet?








Offline SpiroH

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 729
  • Rating: +153/-23
    • View Profile
Re: TI84+ soundchip - arduino SID emulator
« Reply #40 on: January 18, 2013, 01:13:17 pm »
I tried to optimize the arduino code, but it's not getting an awful lot faster since my first optimization.
....
Well, i do not have the whole program picture, so it is not very easy to comment. However, i do see you are polling some bit (PIN3L), what is bound to be always slow. Can't you use interrupts instead, saving cpu cycles to do other things? http://www.cab.u-szeged.hu/linux/doc/khg/node19.html
My two cents.

Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: TI84+ soundchip - arduino SID emulator
« Reply #41 on: January 18, 2013, 01:43:42 pm »
I already use timer interrupts for the sid emulation library. Can I use these in parallel?

Edit: I watched the signal on the scope. The bits take 270 microseconds each to send with the current code on my calculator. When I decrease the delays in the calculator code the arduino cannot keep up with it anymore and I just hear scrambled sounds every now and then.

To send 3kB at this rate it takes about 7 seconds, so that is around 420B/sec.
I think this is as good as it gets. I will just optimize the send protocol for playing music and I write another one optimized for soundeffects. I do not want any visible slowdowns during games, so that's my goal.
« Last Edit: January 18, 2013, 02:10:26 pm by Keoni29 »
If you like my work: why not give me an internet?








Offline SpiroH

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 729
  • Rating: +153/-23
    • View Profile
Re: TI84+ soundchip - arduino SID emulator
« Reply #42 on: January 18, 2013, 02:26:32 pm »
I already use timer interrupts for the sid emulation library. Can I use these in parallel?
Yes, as long as you take care of the relative synchronization. It can be a bit more awkward to program, though.

Quote from: Keoni29
.. I watched the signal on the scope.
If you have available spare output bits, you can also use the scope to 'debug' the program.

Anyway, as long as you are happy with the sound, i wouldn't put much more effort into it, at this stage.


Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: TI84+ soundchip - arduino SID emulator
« Reply #43 on: January 20, 2013, 09:32:15 am »
I want to make a piano roll style music editor or a tracker to make music with. I also need a file format that works. My old TRAXE tracker format does not cut it. Suggestions?
http://ourl.ca/18194
If you like my work: why not give me an internet?








Offline MGOS

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 336
  • Rating: +95/-0
    • View Profile
Re: TI84+ soundchip - arduino SID emulator
« Reply #44 on: January 20, 2013, 09:52:20 am »
That's my piano roll music editor and player I made a while ago. It uses the Freq() function of axe, so the quality is pretty bad but it works quite well though.

http://ourl.ca/14703