Shop OBEX P1 Docs P2 Docs Learn Events
Crescendo — Parallax Forums

Crescendo

Ahle2Ahle2 Posts: 1,179
edited 2021-02-02 12:50 in Propeller 2

Description of this project...

Crescendo - Concurrent REtro Sound Chips Emulator Neatly Devised in an Object.

Comments

  • Ahle2Ahle2 Posts: 1,179

    Place holder

  • Sounds exciting :D can't wait to see this in action @Ahle2 :D

  • roglohrogloh Posts: 5,786
    edited 2021-02-03 01:05

    Yeah sounds good Ahle2. Will this be an object that interoperates with your prior P2 sound mixer object or something more standalone/self-contained?
    Also did you get a chance to try any HyperRAM based audio? I know you were interested a while back.

  • Ahle2Ahle2 Posts: 1,179

    @roghloh,

    It will be running in a single cog, emulating many sound chips at the same time (configurable... like 2 x SIDs + 1 x YM2149F + 1 x NES APU or why not just 8 x SIDs ) and it will output sound on 1 up to 8 pins with panning/volume control. (just like reSound). It should be easy to make it interoperable with the reSound sound driver / mixer to have many simultaneous sample channels and wave audiostreams, mixed in with the emulated chips. When all this comes together, it will be A LOT of fun! :smile:

    I am very excited about your HyperRAM driver and if I just had some more time for this hobby, I would already have had something to demonstrate to you; But having a baby and a toddler, working full time and fixing with our new house, my time to spend on the P2 is almost null atm.

    My worst remorse, though, is that I have promised Chip and Parallax to help them out with creating certain objects and I'm not able to deliver them in a reasonable time. This eats away at my conscience. It REALLY does! :( I have done some work and it looks good, but I have nothing that is finished enough to demonstrate to Chip.

    Another thing that bothers me a little is that my work that I have already done on the P2 seems to have been somewhat forgotten and people asks for things that already exists.

  • Ahle2Ahle2 Posts: 1,179

    @Baggers,

    I love seeing you back on the forum after such a long time in the wonderful world of the Spectrum! :smile:
    We just have to have a new collaboration on something game related (remember H.E.R.O on the P1 many years ago? It was more enjoyable with sound! :wink: )

  • Yeah I remember it :D love that game! Baggers In Space ( recently released for the ZX Spectrum Next ) was a homage to Jet Pac and H.E.R.O. you start off like Jet Pac, then instead of fuel dropping down a box of TNT drops down giving you 6 sticks to then blow holes in the ground and go find the fuel :D

    And yeah it's great to be back, loving playing with the Prop 2 :D

  • cgraceycgracey Posts: 14,151
    edited 2021-02-04 15:09

    @Ahle2 said:
    My worst remorse, though, is that I have promised Chip and Parallax to help them out with creating certain objects and I'm not able to deliver them in a reasonable time. This eats away at my conscience. It REALLY does! :( I have done some work and it looks good, but I have nothing that is finished enough to demonstrate to Chip.

    Ahle2, I am not disappointed, at all. You don't need to worry about this. I know you are busy with life, but I am very pleased that you are enthused about things. There's no expectation on my part. So, just let all that go. I am happy about things, just as they are. I would have said so earlier if I had known you were feeling this way.

  • @Ahle2 said:
    @roghloh,

    It will be running in a single cog, emulating many sound chips at the same time (configurable... like 2 x SIDs + 1 x YM2149F + 1 x NES APU or why not just 8 x SIDs ) and it will output sound on 1 up to 8 pins with panning/volume control. (just like reSound). It should be easy to make it interoperable with the reSound sound driver / mixer to have many simultaneous sample channels and wave audiostreams, mixed in with the emulated chips. When all this comes together, it will be A LOT of fun! :smile:

    This all sounds really useful for audio emulation Johannes. Take your time, I'm sure it will be worth the wait. IMO the P2 is meant to be fun, not work. :smile:

  • Ahle2Ahle2 Posts: 1,179

    @Baggers,
    Wow, I really like Baggers in space... It's a little bit of Cybernoid in there as well. :smiley:

    @rogloh
    Yeah, you are right, it's meant to be fun; That's the whole motivation for doing this.

    @cgracey
    Thank's Chip. 10 years ago, before marriage, wife, house and kids, I could spend as much time as I wanted on this hobby after work. I had multiple big projects going on at the same time. To be honest, I didn't understand that a family life with small kids would mean that I would have almost no time doing any hobbies. STILL I would never want to get back to my life as a single, without all the happiness and love that comes from the family; But, at least I got to program the P1 for a living in a commercial product. I have even put a software synthesizer in there (running in dedicated cog) instead of that awful 1 kHz square wave beeper that have been the standard for industrial equipments for half a centurie. :wink:

  • The fun part is what it's all about, it's just so much fun coding on the P2, just as it was coding for the P1 also.

  • pik33pik33 Posts: 2,366
    edited 2021-02-06 20:50

    Pokey... Maybe I will try to implement this if it is not on the list. My first computer was an 8-bit Atari. I think it can be fully implemented in one P2...

    Of course... time.

    And a P2 board, which will arrive... maybe next week. At last. It left the customs office in Friday after over 2 months journey from USA. A SIDCog will be one of first objects I will try on it...

  • Ahle2Ahle2 Posts: 1,179

    Feel free to do the Pokey, it's not on my list and maybe I could incorporate it into Crescendo when you are done?

  • pik33pik33 Posts: 2,366
    edited 2021-02-08 21:05

    After initial learning it will be one of first thing I want to write. I also need a 6502 to play .sap files, but then a 6502 is needed also by SID.
    I don't want to plan anything now, simply learn and go with the flow.

    Several years ago I wrote this: https://sourceforge.net/projects/pc-softsynth/ - an unfinished but working piece of code which emulates Atari Softsynth, the program which uses Pokey as a 4-channel, 4-bit sampler. PC Softsynth can read a Basic-like Atari Softsynth code and play it at 44100/16. I have a fidelity in mind writing this, advanced Softsynth tunes uses side effects, like aliasing, to make sound effects so I had to emulate 11 kHz aliasing in my code when needed and avoid when not needed.

    This is a PC-Softsynth rendered tune: http://eksperymenty.edu.pl/images/mp3/opswiata1.mp3
    And this is the original:

  • Ahle2Ahle2 Posts: 1,179

    I actually have a real SID player for the P1 laying around. It plays .sid files and it's made by Kuroneko; But he never officially released it. He didn't implement the undoccumented opcodes (neither did I in my 6502 core in the dumper), but some tunes that played wrong as .dmp files worked correctly and that way I knew that SIDcog was not the reason for some tunes to misbehave.

  • Ahle2Ahle2 Posts: 1,179

    I just rewatched my own SIDcog demo from 2010 on YouTube; The P2 is many times as powerful and it will be awesome to continue my sound chip emulation efforts on this fantastic chip. (thank you @cgracey!)

  • pik33pik33 Posts: 2,366
    edited 2021-03-04 10:16

    Sidcog P2 optimization started :)

    1. getrnd can be used for noise, as (unlike POKEY) SID has a long, near perfect noise generator, 2 instructions saved when noise is used
    2. multiply, optimized and unrolled. It is called 7 times in the main loop, which costs 42 cycles. then instead of mov-shr getword can be used. Ret instruction is not needed. 14 cycles saved, 56 cycles per loop gained on the MUL optimization

    As it is now, it uses ~500 cycles per loop (and this gives SID/2 @ 250 Mhz), but time to time it can go over 600. To be continued.

    In the state I have it now it can run at SID/2 @ if the cpu clock is >320 MHz

    The attached demo displays clock cycles per loop - current and max - if HDMI output is attached to #48..55 and plays audio @ #6,#7. Compiles with a Propeller Tool. Work in progress, I may have added bugs while optimizing this :) and converting to Propeller Tool

    Edit: change this line: (there is 4.0 there in the attached file).. and I don't know yet if I have to change resonance constants
    ENV_CAL_FACTOR = 545014038.181330/16.0

  • Ahle2Ahle2 Posts: 1,179

    @pik33
    Please, nooOOooo..... The noise sounds way of using something that is close to real random (as xoroshiro). The SID chip has a VERY distinct noise generator and it took me a while to fake SIDcog to almost sound like the real SID chip. Doing it the same way as the real SID would have increased both code space and cycle count a lot so it was not an option on the P1. In my opinion (and most SID fans) it is NOT worth having a higher sample rate at the cost of decreasing accuracy so much as the noise "fix" does. The 250 kHz I achieved without decreasing the noise quality is plenty good!

    Other than that.... great work, I have to test this out! :smile:

  • pik33pik33 Posts: 2,366
    edited 2021-03-04 10:32

    The noise thing saves 4 cycles per channel IF USED, so it is not critical there. The main gain was unrolled multiply.

    I did this thing for my RPi SID :smile: - a real SID coefficients noise polynomial. Big and greedy, but there was a room for this in RPi3

    p209:          cmp r1,#8                // noise
                   bne p204
                   ldr r7,[r4,#0x3C]
                   cmp r7,#1
                   bne p204
    
                   mov   r7,#0
                   mov   r2,#0
                   mov   r3,#0
                   ldr   r0,[r4,#0x38]
                   tst   r0,#4194304
                   orrne r7,#128
                   orrne r2,#1
                   tst   r0,#1048576
                   orrne r7,#64
                   tst   r0,#65536
                   orrne r7,#32
                   tst   r0,#8192
                   orrne r7,#16
                   tst   r0,#2048
                   orrne r7,#8
                   tst   r0,#128
                   orrne r7,#4
                   tst   r0,#16
                   orrne r7,#2
                   tst   r0,#4
                   orrne r7,#1
                   tst   r0,#131072
                   orrne r3,#1
                   eor   r2,r3
                   orr   r2,r2,r0,lsl #1
                   str   r2,[r4,#0x38]
                   sub   r7,#128
                   lsl   r7,#16
                   str   r7,[r4,#0x28]
    
    
  • Ahle2Ahle2 Posts: 1,179

    Btw, Crescendos SID emulator is a new implementation and just uses bits and pieces of the SIDcog code. The main goal is to have accuracy as much as possible while still not going below 250 kHz for common system clocks.

  • @pik33
    I noticed a few things in your demo above that required fixes to get it to work (at least with FlexSpin). If anyone wants to play this demo, they'll need the same things done...

    The dmp filename needs to be changed in SIDcog.spin2 to play the included .dmp file not the lamebada.dmp which is not in the .zip

    dumpFile            file "Autumn_Symphony.dmp" ' was file "lamebada.dmp"
    

    The final errors below is because the absolute address for stack is not liked by Fastspin compiler. Got it working by creating a small stackbuffer in the VAR section and passing its address instead of hard coding to $70000.

    cogspin(16,sid.demo(),@stackbuf[0]) '  was ,$70000)
    

    Also this compare on line 812 of hn007.spin2 is not setting flags needed for the next instruction mentioned in the final warning below...it doesn't seem correct, but played regardless, maybe less than optimal. It seems to trash the ending.

                    cmp     t1,#257   ' MISSING wcz
             if_lt  wrlut   t2,t1
    

    All those other warnings are because of not using the "0-0" syntax after the alts. But they are not real problems.

    Propeller Spin/PASM Compiler 'FlexSpin' (c) 2011-2021 Total Spectrum Software Inc.
    Version 5.0.8 Compiled on: Jan 24 2021
    main.spin2
    |-sidcog.spin2
    |-hn007.spin2
    /Users/roger/Documents/Code/p2videodrv/demo/pik/sidcog/sidcog.spin2:159: warning: Second operand to mov is a constant used without #; is this correct? If so, you may suppress this warning by putting -0 after the operand
    /Users/roger/Documents/Code/p2videodrv/demo/pik/sidcog/sidcog.spin2:162: warning: Second operand to mov is a constant used without #; is this correct? If so, you may suppress this warning by putting -0 after the operand
    /Users/roger/Documents/Code/p2videodrv/demo/pik/sidcog/sidcog.spin2:165: warning: Second operand to mov is a constant used without #; is this correct? If so, you may suppress this warning by putting -0 after the operand
    /Users/roger/Documents/Code/p2videodrv/demo/pik/sidcog/sidcog.spin2:190: warning: Second operand to mov is a constant used without #; is this correct? If so, you may suppress this warning by putting -0 after the operand
    /Users/roger/Documents/Code/p2videodrv/demo/pik/sidcog/sidcog.spin2:193: warning: Second operand to mov is a constant used without #; is this correct? If so, you may suppress this warning by putting -0 after the operand
    /Users/roger/Documents/Code/p2videodrv/demo/pik/sidcog/sidcog.spin2:196: warning: Second operand to mov is a constant used without #; is this correct? If so, you may suppress this warning by putting -0 after the operand
    /Users/roger/Documents/Code/p2videodrv/demo/pik/sidcog/sidcog.spin2:218: warning: Second operand to mov is a constant used without #; is this correct? If so, you may suppress this warning by putting -0 after the operand
    /Users/roger/Documents/Code/p2videodrv/demo/pik/sidcog/sidcog.spin2:221: warning: Second operand to mov is a constant used without #; is this correct? If so, you may suppress this warning by putting -0 after the operand
    /Users/roger/Documents/Code/p2videodrv/demo/pik/sidcog/sidcog.spin2:224: warning: Second operand to mov is a constant used without #; is this correct? If so, you may suppress this warning by putting -0 after the operand
    /Users/roger/Documents/Code/p2videodrv/demo/pik/sidcog/hn007.spin2:812: warning: instruction cmp used without flags being set
    main.p2asm
    main.p2asm:184: error: Bad use of immediate for first operand of add
    main.p2asm:186: error: Bad use of immediate for first operand of add
    Done.
    Program size is 317976 bytes

  • pik33pik33 Posts: 2,366
    edited 2021-03-04 12:05

    It took me some time to make the original sidcog demo work in the Propeller Tool We seem to have 2 compilers which are incompatible which makes to do addiional effort if the program has to run using both of them.

    So it seems I have to use both of them to test.

    The demo has no end; when the file is over, it plays the rest of P2 memory which is of course garbage.

    Edit: this no wcz error caused the value to be written to the LUT at position 257, which is invisible as it is used in the main loop and overwritten there. The desired behavior is: if 257, do nothing; if less than 256, write a new color value to LUT, then set the variable to 257, signalling command done. This should be cmp t1,#256 wcz


    I compared these noises (using ears; no spectrum analyser available now): the getrnd noise is "more random" - more "white" than the noise generated in SIDCog; it has more high frequency components in it.

  • Ahle2Ahle2 Posts: 1,179
    edited 2021-03-04 13:58

    pik33,

    But the SID chip is FAR from random and that's why it took me days to make a noise generator that sounded close to the real SID, but doing it in a completely different way. Please don't underestimate my effort. SIDcog didn't take an hour to make!

Sign In or Register to comment.