Shop OBEX P1 Docs P2 Docs Learn Events
Music Synthesizer object with General MIDI sound set - Page 4 — Parallax Forums

Music Synthesizer object with General MIDI sound set

124»

Comments

  • Lord SteveLord Steve Posts: 206
    edited 2010-12-17 20:35
    Ariba,

    Could you go over how the idea in general and the code in particular of how you affect the phase accumulator (or is it the frequency register?) of the first operator by the amplitude(?) of the second?

    Also, what is the difference between what you do here (phase modulation) and real frequency modulation? How can we do real FM?

    Thanks!
  • AribaAriba Posts: 2,682
    edited 2010-12-18 09:44
    Lord Steve wrote: »
    Ariba,

    Could you go over how the idea in general and the code in particular of how you affect the phase accumulator (or is it the frequency register?) of the first operator by the amplitude(?) of the second?

    Neither the phase accumulator nor the freq register is affected by the modulation. The modulation is done after the DDS calculation by adding the modulation wave to the phase before looking up the waveform from the wave-table (OK I have no wave-lookup tables but something similar, and its easier to visualize it with a table).
    attachment.php?attachmentid=76453&d=1292694213

    If the modulation is zero, the phase increases linear and reads out the Triangle wave from the lookup table. With modulation the phase iincreases no more linear. If the modulation sample is negativ the phase grows slower otherwise faster. The following picture shows 2 modulation intensities in blue and red. Here the modulation wave is in sync and has the same frequency to make it simple.
    As you see the read out waveform from the table gets changed from a triangle to a sawtooth wave. If the modulation frequency is not the same as the carrier you get totally different waveforms, but all these waveforms go back to a triangle if you lower the modulation intensity. So compared with a normal subtractiv synthesizer we can say: The frequency ratio defines the waveform and the modulation intensity the cutoff frequency.
    attachment.php?attachmentid=76454&d=1292694214
    Lord Steve wrote: »
    Also, what is the difference between what you do here (phase modulation) and real frequency modulation? How can we do real FM?
    You can do a real FM if you accumulate the modulated phase value in the PHASE register instead of the unmodulated (the green line in the first picture). But this is very uncommon, because it can result in odd frequencies if the modulation is not totally symmetrical. Also Yahama does in reality a Phase modulation, also if they call it FM.
    The big difference to the real FM-Synthesizers is that they work with Sinus instead of Triangle waves and that they have more oscillators in more combinations per voice.
    It may be possible to do a more advanced FM synthesis but I think you get then only 1 voice per cog.

    Andy

    DDS_PM.gif
    PM_Wave.gif
    368 x 138 - 2K
    243 x 148 - 1K
  • Lord SteveLord Steve Posts: 206
    edited 2010-12-18 09:55
    Ah! I was multiplying the frequency0 register by the phase1 register before looking up phase0. I tried just adding the phases like you said and it worked! Much faster than a multiply, too! Thanks a lot, this is so cool.

    I've been working on modeling sine waves with parabola segments (just for the fun of it) and wanted to integrate that idea with ideas from your synth. Great object, and very inspirational. Thanks for making it.
  • John A. ZoidbergJohn A. Zoidberg Posts: 514
    edited 2012-04-05 23:46
    Hello Andy,

    I've looked in through the code, especially the synthesizer part, and I'm very amazed that you used triangle wave instead of a sine. Looking at the fourier transform of the triangle wave, the other harmonics are quite "diminished", hence of the "sine-wave sounding".

    However, I'm curious about how did you manage to manually calculate the triangle wave without using any branches.

    All I went on the pseudocode was this:

    if(accumulator < pi)
    accumulator += phase
    else
    accumulator -= phase

    if(accumulator > max_accumulator)
    accumulator = 0;

    The code is inefficient of course, and yours are much more better than mine.

    I'm using this into the dsPIC, cranked up to 80MHz of course. :)
  • average joeaverage joe Posts: 795
    edited 2012-04-06 01:20
    Andy, great work! I just loaded up the midi moul on my synth hardware and ended up playing with it for about half an hour! I could only find a handful of patches. I'm curious as to which patches are actually implemented.
  • Ahle2Ahle2 Posts: 1,178
    edited 2012-04-06 01:35
    @John A. Zoidberg

    Making a triangle wave is easy.
    [SIZE=4]If MSB of accumulator is set
      sample := accumulator << 1
    else
      sample := (~accumulator) << 1[/SIZE]
    

    And using the awesome Propeller instruction set it's even easier:
    [SIZE=4]abs  sample, phaseAccumulator
    shl  sample, #1[/SIZE]
    
  • RaymanRayman Posts: 13,800
    edited 2012-04-06 03:58
    I just re-read this first post and noticed this code requires converting midi from type 1 to type 0.

    The program I use now to do this is called "gn1to0". This is what VLSI.com recommends for use with their VS1003 MP3/midi player chip.
    Haven't tried it with this code, but I think it will work...
  • John A. ZoidbergJohn A. Zoidberg Posts: 514
    edited 2012-04-06 04:31
    @Ahle2

    Thanks for the pseudocode. I'll just translate it and modify for my dsPIC in the interrupt. :)
  • average joeaverage joe Posts: 795
    edited 2012-04-06 04:45
    I was just playing around with this object and loaded up a song for S&G. So here's "Tool -Stinkfist" on the GM sound set. I did use "real" drums and bass, because the drums didn't come out well on the GM set.
    Any comments, suggestions or requests appreciated!
    http://soundcloud.com/joe-heinz/stinkfest-on-proper-midi-synth
    Thanks again Andy for this wonderful object!
  • John A. ZoidbergJohn A. Zoidberg Posts: 514
    edited 2012-04-06 05:40
    I was just playing around with this object and loaded up a song for S&G. So here's "Tool -Stinkfist" on the GM sound set. I did use "real" drums and bass, because the drums didn't come out well on the GM set.
    Any comments, suggestions or requests appreciated!
    http://soundcloud.com/joe-heinz/stinkfest-on-proper-midi-synth
    Thanks again Andy for this wonderful object!

    I like the soundtrack. It's very in a 80s in style. It would fit certain 90s old video games for sure too. :)
  • GordonMcCombGordonMcComb Posts: 3,366
    edited 2012-04-06 08:31
    So here's "Tool -Stinkfist" on the GM sound set. I did use "real" drums and bass, because the drums didn't come out well on the GM set.
    Any comments, suggestions or requests appreciated!

    Nice sample! Thanks for posting. Can you post the mid file? Is it sharable? What synth did you use for the bass and percussion?

    -- Gordon
  • average joeaverage joe Posts: 795
    edited 2012-04-06 09:01
    A big thanks! Here's the midi file I used. I have a VERY complex setup, so I won't get into all the details. Basically I use Ableton LIVE to map and playback the midi file. I use Reason 4.0 for the sounds. I also did a sample of Skrillex - Scary Monsters and Nice Sprites
    http://soundcloud.com/joe-heinz/skrillex-scary-monsters-and
    Also, I remixed an original song with as well
    http://soundcloud.com/joe-heinz/give-me
  • GordonMcCombGordonMcComb Posts: 3,366
    edited 2012-04-06 09:46
    Also, I remixed an original song with as well
    http://soundcloud.com/joe-heinz/give-me

    Love it! Angry bees!! This reminds me of the classic analog synth licks that you just don't hear today. Catchy tune, too.

    I take it the lead piano isn't from the FM synthesis.

    -- Gordon
  • average joeaverage joe Posts: 795
    edited 2012-04-06 09:55
    Thanks again! Actually it's ALL the FM *well PM but why split hairs* except drums and the "wobble" bass. I think I might have had a "piano/strings" layer mixed in slightly for a little extra phatness!
    I will get to your PM in a bit, gotta change a water pump on a POS Ford first :(
  • AribaAriba Posts: 2,682
    edited 2012-04-06 10:26
    Hello Andy,

    I've looked in through the code, especially the synthesizer part, and I'm very amazed that you used triangle wave instead of a sine. Looking at the fourier transform of the triangle wave, the other harmonics are quite "diminished", hence of the "sine-wave sounding".

    However, I'm curious about how did you manage to manually calculate the triangle wave without using any branches.

    All I went on the pseudocode was this:

    if(accumulator < pi)
    accumulator += phase
    else
    accumulator -= phase

    if(accumulator > max_accumulator)
    accumulator = 0;

    The code is inefficient of course, and yours are much more better than mine.

    I'm using this into the dsPIC, cranked up to 80MHz of course. :)

    Hi John

    I also have some dsPICs here intendet for sound synthesis (there is one with a 16Bit stereo DAC). But I had not the time to play with them, so far...

    Regarding Triangle: As Ahle says the simplest way is just to build the absolute value of the sawtooth which you get directly from a DDS generator. See post #60 of this thread, I tried to explain it there. The resulting triangle has a DC offset so you should also subtract this offset:
    abs  tri,saw
      sub tri,offset
      ...
    offset  long  $4000_0000
    

    Andy
  • AribaAriba Posts: 2,682
    edited 2012-04-06 10:38
    @average joe

    It's nice to hear that someone with MIDI equipment plays with my little synth. I know the drums are not the highlight of the object, drums really need sound-samples today, FM or PM is a bad architecture for that. Also the accoustic guitar sounds could need some improvements.

    I did some experiments with single cycle wave samples, which are played by one cog and modified by a second cog (filtered, envelope volume). These experiments may result in another MIDI synth object one day.
    Another idea is to play long wave samples from SD card for drums together with PM synthesis for instruments, I think playing 4 samples at the same time should be enough for that.

    Andy
  • average joeaverage joe Posts: 795
    edited 2012-04-06 11:07
    Midi drums are always difficult to make sound right. The drum samples I use are HEAVILY processed. Guitars are another story completely. Being a guitar player, I despise midi guitars. Even the most expensive synths I've played don't sound right, even playing the RIGHT NOTES! I have tried sampling my guitar and come up with better results, but only after extensive work. Getting FM guitars and drums sounding GOOD is not something I consider possible. I do think your drums could be used for noise generation, but need to play around a bit more.

    I have been thinking about building a hardware base for DDS or DCO based system. I've got some ssm 2044 LPF chips I want to build a filter for. I also have several VCA's that would go well in an analog synth. I would be really interested in checking out your sampled-based synth when you get around to working on it. Playing long samples from an SD card would be ok, but I would go for loading samples to RAM and from RAM to DAC. I know this requires more hardware, but I think it offers some unique benefits. I have been thinking about adapting a circuit similar to the counter based RAM Dr Acula and I are working. This thread http://forums.parallax.com/showthread.php?137999-LCD-touchscreen-A-development-thread has a bit about the hardware I'm working on. My current hardware is similar to post #84. The new hardware will be something like post #144. Any thoughts? I'm still waiting for parts to get started, but will keep you updated!
  • AribaAriba Posts: 2,682
    edited 2012-04-06 11:52
    I only compare my synth with other synthesizers, not with real accustic instruments. You never reach the sound of a real guitar especially if played solo.
    And for sure if my synth were as good as the best commercial synths, I never would release it for free as an object ;-)

    I've made already a lot of hand drawing schematics for Propeller driven analog synthesizers. But not realized one so far.
    The Propeller is ideal to produce DCOs with it's counters and then control some analog filters and VCAs. Something like my Oberheim Matrix 6. At the same time another cog can play some sound samples. Another cog can decode the MIDI stream and control all the synthesis cogs.

    Yes if you have a big RAM for sound samples, you can play more of them at the sime time than direct from SD card. With some Hub-FIFO buffer for every voice (=caching) you don't need a complicated hardware for the RAM.

    But when I think about it, I always came to the conclusion that the Prop 2 will be much better to do what I want. There are a lot of DACs and Hardware multipliers and SD-RAM interface and ... I just not knew that I have to wait so long...

    Andy
  • Ahle2Ahle2 Posts: 1,178
    edited 2012-04-06 12:30
    @average joe
    Why not use a bounce of CEM3394 as a basis for a Propeller controller polyfonic analog synthesizer?
    It may be a little bit like cheating, but it's an easy way to get started.
    I know it sounds good because it's the chip used in Doepfer Dark Energy; And I happen to have a Dark Energy sitting next to me right now. :)
    DSC00260.jpg
    1024 x 768 - 89K
  • average joeaverage joe Posts: 795
    edited 2012-04-06 12:52
    @Johannes, the CEM 3394 is a great chip, but a bit difficult to find. If I ever get my hands on one, I will have to get it working. There are several chips that would provide a jump start, but I think in the end they would limit flexibility. Of course I could be wrong.

    @Andy, I did a side by side comparison with my Roland CM-64 (MT-32 and PCM) and it is on par with MT-32 IMO... *gotta run, TBC*
  • laurent974laurent974 Posts: 77
    edited 2016-04-15 19:09
    Fantastic software!

    i put it on my activity WX board

    I simply changed this configuration pin inside the file midi_player
      SD_basepin      = 22       '<-- SD card
      Left            = 26      '<-- Audio Out pins
      Right           = 27
    
Sign In or Register to comment.