Author Topic: C# PadSynth Implementation  (Read 4435 times)

0 Members and 1 Guest are viewing this topic.

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
C# PadSynth Implementation
« on: July 11, 2012 »
I've been planning on implementing the PadSynth algorithm into my synth and finally got around to having a play around with this stuff. I decided to make a test app in C# before writing a C++ for implementation for the synth.

Attached is a little C# app (with source), that generates a few PadSynth wavetables and lets you play them back. There seems to be a bug with the Guitar sounds as they overdrive/distort even at very low volumes. I'll have a look at that and hopefully fix it up tonight or tomorrow. There are no keyboard controls or anything like that, so everything plays at a fixed pitch.

I'll post again later with a bit more info.

Cheers,

Raizor
raizor

Challenge Trophies Won:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: C# PadSynth Implementation
« Reply #1 on: July 12, 2012 »
Sounds nice. Good job!
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: C# PadSynth Implementation
« Reply #2 on: July 12, 2012 »
Thanks Benny. I'll add some more stuff I've found out into the Synth topic tomorrow, it may interest someone, or at least do my mind some good to talk about it :)
raizor

Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: C# PadSynth Implementation
« Reply #3 on: July 12, 2012 »
Nice find, I need to do some tests myself.  :kewl:
Challenge Trophies Won:

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: C# PadSynth Implementation
« Reply #4 on: July 13, 2012 »
Nice find, I need to do some tests myself.  :kewl:

I've converted it to C++ now, I've attached it in a RAR.  You'll need to change the Memset call and supply the sample rate as these are stored in other files in my Synth, but you should be able to get it running fairly easily.

Note that the numSamples value should be a power of 2. The value 2 ^ 18 (262,144) seems to work quite nicely and gives you a wavetable that takes ~512kb of mem. I discovered yesterday that the amplitude/volume of the output depends on the size of numSamples. The lower the value of numSamples, the great the amplitude of the output. The code doesn't take this into account at the moment, so if you going to be generating variable length PadSynth wavetables, remember to take this into account. I should have a magic number of amplitude scaling soon, which I'll share. Obviously the memory usage gets quite high with bigger wavetable sizes, but the bigger the wavetable, the smoother the sound. You end up with quite noticeable tremolo when using low numSamples values. 

EDIT: I'm currently using a wavetable per octave but there's a noticeable change in the output between the wavetables (due to missing harmonics I think). You can really hear this when it switches wavetables while playing a set of ascending or descending notes. Still working this out, going try mixing between the wavetables to see if that helps.

EDIT: Oops, seems my problems with varying volume/amplitude were due to not normalizing the wavetable samples after generation. Updated the attached code. Also added defines for memset, samplerate and PI, so just change these to point to your own stuff if you use it. I'll get round to optimizing this at some point, it's fairly small and fast already though.
« Last Edit: July 13, 2012 by Raizor »
raizor

Challenge Trophies Won: