Shop OBEX P1 Docs P2 Docs Learn Events
Patched SIDCog - MUL used, 64 kHz sampling, 12 dB/oct filter — Parallax Forums

Patched SIDCog - MUL used, 64 kHz sampling, 12 dB/oct filter

pik33pik33 Posts: 2,366
edited 2014-11-03 10:27 in Propeller 1
In the post #7 I uploaded a version of it which seems to be good enough. It still needs tuning

Comments

  • pik33pik33 Posts: 2,366
    edited 2014-10-29 00:14
    As I thought before there is still something to change - the filters need update, too; changing sampling frequency causes filter parameters shift. I have now to find what parameters are to be changed for them to work properly.
  • pik33pik33 Posts: 2,366
    edited 2014-10-29 02:25
    The author of SIDCog needed... I still don't understand in details how SID filters should work. And I cannot send him a private message because he has his mailbox full.
  • pik33pik33 Posts: 2,366
    edited 2014-10-29 06:08
    Filter still doesn't work as expected; there are some other parameters to change. Still, it is worth to do it, the 64 kHz version sounds better (until the filter is not used)
  • pik33pik33 Posts: 2,366
    edited 2014-10-29 06:41
    ( The Post #7 contains the first version worth uploading )
  • roglohrogloh Posts: 5,791
    edited 2014-10-29 21:34
    @pik33

    I had modified the SIDCog sample rate a while ago. I believe you also need to modify ENV_CAL_FACTOR accordingly.

    I just looked at my modified code from back then and I found I had reduced C64_CLOCK_FREQ from 985248.0 to 705600.0 and had also changed ENV_CAL_FACTOR by the inverse ratio (ie. I increased it by the ratio 986248/705600). I recall it sounded okay to my ears at the time but that was a year or more ago now. See if that helps you.

    Roger.
  • pik33pik33 Posts: 2,366
    edited 2014-10-30 01:38
    There is a version which seems to work properly.

    It still need a tuning - I have too low knowledge about real SID.

    The real SID had 12 dB/oct filters, where sidcog filters was 6 dB/oct. Now there was place for 12 db/oct, which I did by simply adding the second filter block.

    So there it is sidcog for p1v retromachine, with 64 kHz sample rate and 12 dB/oct filters.

    I removed all these yesterday's trials.
  • Ahle2Ahle2 Posts: 1,179
    edited 2014-10-30 08:44
    This is great!! :):)

    I wish the Prop1 would have had a multiplication instruction from the start, then we could have done this a long time ago.
    Can you record some tunes with heavy filter usage, so I can have listen?! I don't have my DE2-115 available ATM.

    /Johannes
  • pik33pik33 Posts: 2,366
    edited 2014-10-30 09:26
    Can you give some titles?
    And.. look at this code - I left one bandpass stage - there is 6 dB/oct bandpass in the sid documentation
    And these constans... I don't fully understand them. Then there is a noise generator - maybe it needs changes too...
  • Ahle2Ahle2 Posts: 1,179
    edited 2014-10-30 11:52
    One of the tunes from the links below (or all of them) would be great to hear with your 64 kHz version.

    Here are recordings made with SIDcog 1.2 (32 kHz) from a couple of years ago as a reference!
    [video]
    [video]
    [video]
    [video]

    /Johannes
  • pik33pik33 Posts: 2,366
    edited 2014-10-30 12:33
    Can you attach a .dmp of them?
  • pik33pik33 Posts: 2,366
    edited 2014-10-31 01:18
    To make these tunes I had to (1) find SIDs (2) find tools (3) prepare .dmp

    So there are some files I have ready now: Zelda and Da Winner. A short fragments, about 1 minute, mp3
  • 65816581 Posts: 132
    edited 2014-10-31 03:41
    @pik33: Sounds really nice. The only thing I notice is some aliasing in the dawinner.mp3 - am I right
    or is it just some artifact in the beginning of this tune?
  • 65816581 Posts: 132
    edited 2014-10-31 03:46
    Here are some more DMPs, if you want to have more files to test.

    collection2.zip
  • pik33pik33 Posts: 2,366
    edited 2014-10-31 03:56
    There are 2 sources of these aliases. (1) 64kHz->44100Hz in the retromachine without any filtering (todo) (2) recording and mp3 compression. These aliases in Da Winner are less hearable directly from the hardware than after recording.

    The proper solution is a filter between sidcog output and sound chip on DE2-115. Even simple one will do its job.
  • Ahle2Ahle2 Posts: 1,179
    edited 2014-11-01 10:24
    I will have a look in the code as well, but just by listening to the recordings it seems like you got most of the changes right.
    Here are the dumps so you can make records, then it will be easier for me to hear if anything sounds wrong.

    HeavyFilterSidDumps.zip

    /Johannes
  • pik33pik33 Posts: 2,366
    edited 2014-11-01 11:45
    So here they are.

    And now I need to add antialias filter between a sidcog and a soundchip to get rid of these aliases.
  • pik33pik33 Posts: 2,366
    edited 2014-11-02 02:43
    We have mul!

    So instead
                  shl       frequency2, #12
    

    I can use
                  mul       frequency2, a5720
    

    and
        sampleRate := 2592
    

    Now the sidcog works in exact synchronicity with the sound chip (all clocks are synchronous in my retromachine); no resampling needed. There is also no need to run it at higher sample rate because the sound chip works @ 44100

    There is now A LOT OF time in the Sidcog main loop. SampleRate is 2592, where it now consumes less than 1500 clocks. We can think about more complex filters, antialias output filter (aliasing which emerges when the harmonics meets the sample rate - the signal should be always high pass filtered) and more SID channels in one cog.
  • pik33pik33 Posts: 2,366
    edited 2014-11-02 07:54
    A result of sidcog working with 44100 Hz sample rate without antialias filter
    Edit: and with simple antialias
  • pik33pik33 Posts: 2,366
    edited 2014-11-02 11:42
    This sample was form sidcog with parameters as below and 44100 Hz plus simple 6db/oct 11025 Hz low pass antialias filter.
      RESONANCE_OFFSET = 6'                 │
      RESONANCE_FACTOR = 6'                 │
      CUTOFF_LIMIT     = 2040'              │
      LP_MAX_CUTOFF    = 12'                │ Don't alter these constants unless you know what you are doing! 
      BP_MAX_CUTOFF    = 11'               │
      FILTER_OFFSET    = 6'                │
      START_LOG_LEVEL  = $5d5d5d5d'         │
      DECAY_DIVIDE_REF = $6C6C6C6C'         │   
      ENV_CAL_FACTOR   = 380508780.53' │ ENV_CAL_FACTOR = (MaxUint32  / SIDcogSampleFreq) / (1 / SidADSR_1secRomValue)   
      NOISE_ADD        = 10_1010_101<<23'&#9474; ENV_CAL_FACTOR = (4294967295 / 30789           ) / (1 / 3907                ) = 545014038,181330
      NOISE_TAP        = 0001 << 8'   ___&#9474;
    
    
  • Ahle2Ahle2 Posts: 1,179
    edited 2014-11-02 13:49
    As far as I can tell you have made all the right changes in the 64 kHz version. :)

    While this effort is great, it just isn't the same thing as having a real Propeller. I can not use it any project of mine. :( Ooooh how a wish the real P1 had a MUL instruction.

    IMHO.... I rather have some aliasing in the audio than a LP filter at 11025 Hz... oooooh the horror of muffled sound... don't even get me started about the "default" audio filter used by almost all Propeller Platforms...The perceived audio quality is WAAAY better without that filter. There are a lot of different ways to handle aliasing, but this approach DEFINITELY is not the right way. I hate aliasing with a passion, but muffled sound makes me want to throw away my 1800 dollar computer sound system... ;)
    A brick wall filter at 22050 sadly isn't feasible on the Propeller though. Oversampling with a simpler filter is another approach, but signal processing isn't part of the strengths of the Propeller.
  • pik33pik33 Posts: 2,366
    edited 2014-11-02 23:06
    You still have a DE2-115.

    We have a MUL. I used a quick and simple 11025 antialias, but we can use a more advanced filter using some MUL instructions; now there is a place for it. 16 kHz, 4th order filter will not muffle the sound. Maybe, for some very young people who can hear up to 20 kHz it will.
  • pik33pik33 Posts: 2,366
    edited 2014-11-03 10:27
    So this is a SIDCog optimized for use with my retromachine. The machine's soundchip works @ 44100 Hz, so, to avoid resampling which causes a lot of aliases the sidcog now works @ 44100 Hz. This is only possible with a mul instruction which allowed me to mul the frequency register by 5720 instead of shl-ing it by 12 (=mul 4096) or 13 (8192)

    Now the filter characteristics are different than in original sidcog. To change this I have to rewrite some filter code using another bunch of mul instructions, but what this version outputs now is not that bad.

    I added the antialias filter which now has ~16 kHz frequency, so it doesn't make the sound dull. This is simple 6 dB/oct filter; I have now some coefficient to make a 4th order Chebyshev filter @ 18 kHz - maybe later.

    The problem with further developing the sidcog now is not the time - I have ~1000 cycles left now. There is problem with the place - it ends @ $1E7 So, now the code should be optimized for size, and not for speed which is not critical in this environment - 88200 Hz is not possible in any way.

    To make the retromachine easier using of sidcog without switching off one of 4 synth channel, I added a new register for it. So I have now a SID chip on board :)

    Attached the modified sidcog and its output.
Sign In or Register to comment.