Shop OBEX P1 Docs P2 Docs Learn Events
Propeller Synthesizer — Parallax Forums

Propeller Synthesizer

AndroidAndroid Posts: 82
edited 2013-06-13 06:54 in Propeller 1
Hello everyone. I am going to attempt to create a simple sytnthesizer with the propeller. It would have 5 controls in total. A pitch control, volume control, and three different effects. Not sure about the programming or the wiring for this. Any help is appreciated.
- Android

Comments

  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2013-06-11 11:21
    Step 1: Look into Retronitus
    Step 2: ???
    Step 3: Profit!
  • AndroidAndroid Posts: 82
    edited 2013-06-11 11:50
    Circuitsoft,
    I am not the most intelligent person with electronics :tongue: so didn't really get what i'm supposed to do with the files on the post. Could you explain?
    - Android
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2013-06-11 11:53
    Read the thread. It's kind of interesting, and after a page or two he describes roughly how it works, with some information on how to use it.

    How do you intend to control your synth? MIDI?
  • AndroidAndroid Posts: 82
    edited 2013-06-11 11:57
    Okay. I was hoping to use the propeller as the controller and have it be more of a tone generator then a synthesizer. Apologies if i was unclear.
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2013-06-11 12:50
    There needs to be some connection between you and the propeller - whether potentiometers or switches, or a mouse and keyboard. If this is for music purposes, then MIDI is probably the best option.
  • AndroidAndroid Posts: 82
    edited 2013-06-11 12:52
    I know how to generate a tone but don't know how to add a potentiometer that when set to a new position changes the tone to a new pitch. Anyone know how?
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-06-11 12:58
    To add a bit to what Circuitsoft said, MIDI is used in a lot of digital instruments to communicate when a note turns on and off (and a bunch of other parameters).

    While many keyboards have built in synthesizers, there are also some piano type keyboards that don't produce music on their own. They require a separate sound generator.

    For example, I have an Alesis keyboard synthesizer but I wanted to learn to play the organ so I added a second keyboard that's just a "controller" meaning it provides information about the notes played but it doesn't produce sound. This "controller" is plugged into the Alesis so when I press a key on the controller, the Alesis generates a sound to go with it.

    While there's lots of ways to generate this note information, it's tough to beat a good keyboard for producing a wide range of notes (it of course helps to know how to play the piano or other keyboard type instrument).

    One project I keep intending to try is a MIDI signal merger. I also have a pedal board which generates MIDI instructions but my synthesizer only has one "MIDI in" port. I have to run the two MIDI signals through a PC in order to merge them. It would be nice to free my two keyboards with foot pedals from the need of having a PC in the mix.

    I think what Circuitsoft was asking was how do you want to tell the Propeller which note to play? One option, as he mentioned, is a potentiometer. Another option would be to use some sort of MIDI controller to generated instructions to the Propeller.
  • AndroidAndroid Posts: 82
    edited 2013-06-12 10:30
    Yea sorry i was really unclear... What i meant for it to be was a potentiometer for pitch control then a few pushbuttons for changing between sawtooth, triangle, and another kind of soundwave. Sorry for being really unclear. :tongue:
  • kwinnkwinn Posts: 8,697
    edited 2013-06-12 11:42
    The propeller can read the position of a potentiometer using an RC circuit and the state of switches and push buttons connected to the I/O pins so a simple tone generator or synthesizer can be built with it.
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2013-06-12 11:43
    Have a look at SIDcog. If you are building a more "retro" synth, it will likely be what you are looking for,

    Here's a project I did using my little PMC project for a SIDcog enable synth that accepts MIDI-in.

    http://www.instructables.com/id/Building-a-Retro-Synthesizer-with-the-Pocket-Mini-/

    Jeff
  • pik33pik33 Posts: 2,366
    edited 2013-06-12 23:06
    Look at this:

    http://linusakesson.net/bitbuf/index.php

    It was made with Atmega88. The Propeller can do much more.

    And this:

    http://linusakesson.net/chipophone/index.php

    is a synth made with two Atmegas 88.

    As I said, the Propeller is much more powerful than Atmega 88. It is much more powerful than two of them, too.

    With the Propeller you can simply make any synth you want.
    There is a midi interface ready in OBEX.
    There is a lot of sound producing libraries
    There is sidcog, a SID emulator, AY emulator, Retronitus and some other synths available here

    Yu only have to look at these parts and make something with them. Or develop a new one :)
  • AribaAriba Posts: 2,690
    edited 2013-06-13 04:48
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2013-06-13 06:54
    There is a huge amount of great work already done for the synths on the propeller. I pulled together some clever audio obex code (which I don't fully understand, but that is the great thing about the propeller, you can use other people's clever code easily) and coupled it with a touchscreen and added some sliders etc that you can control with a pen or finger. Pretty crude and not pushed to the limit by any means, but it does play sound. Behind that screen is a propeller chip, two ram chips and some 30c glue logic chips. I'd call this an advanced project though. If you want to progress it further, it would need some work understanding Spin, Pasm, Eagle PCB, schematics, Paintshop Pro, and a willingness to make multiple revisions of PCBs at $100 a go until you get it right!

    The actual code pulls in code written by others, so I've posted the bit I wrote below.

    Sorry it is a bit blurry on the video. Below is the background file to give an idea of the resolution. Draw the sliders and switches on top of this and set them as active areas on the touchscreen as per the code. Look for touches to the keys and play the sound.
    CON
      _clkmode      = xtal1 + pll16x                        ' use crystal x 16
      _xinfreq      = 5_000_000
       
    OBJ
      tch:           "Touch"                                 ' touchscreen driver
      synth :        "tinysynth"                             ' Thanks Ahle2 http://forums.parallax.com/showthread.php?139724-TinySynth-!
    
    VAR
       long DecRate                 ' synth settings
       long SusLevel
       long PWinit
       long pwmRate
       long Filter
       long Portamento
    
    PUB Main | touchtest  ' debug value
      tch.BeginProgram                                        
      PlaySynthesizer
      tch.SetWarmBoot                                           ' clears screen, sets a warm boot and reboots
    
    PUB PlaySynthesizer | xval,yval,portsw,note ' see next routine for automatic tunes
        synth.start(21, 23)                                 ' start the synth
        portsw := false                                     ' portamento off
        PWinit := 255                                        ' synth settings all 0-255
        pwmRate := 12
        decRate := 200                                      
        susLevel := 255
        filter := 16
        portamento := 6  
        tch.Clearscreen(%00000000_00000000)                 ' 
        tch.ClearRam                                        ' clear all but file 0 and 1
        tch.SDBMPtoRam(string("synth2.bmp"))                ' file 2
        tch.SDBMPtoRam(string("synoff.bmp"))              ' file 3
        tch.SDBMPtoRam(string("synon.bmp"))               ' file 4
        tch.SDBMPtoRam(string("synknb.bmp"))              ' file 5
        tch.SDBMPtoRam(string("synslbk.bmp"))             ' file 6
        tch.DrawBMPRam(2,0,0)                               ' draw the picture
        tch.DrawBMPRam(3,148,241)                           ' draw file 2
        tch.DrawBMPRam(4,148,283)                           ' draw file 3
        RefreshSliders                                      ' draw all the sliders                              
        tch.SelectSPIGroup                                    ' talk to the spi touchscreen
        repeat
          yval := tch.TouchYPercent                           ' decode yval 0-100%               
          xval := tch.TouchXPercent                           ' decode xval 0-100%
          if (xval <> 255)  and (yval <> 255)                    ' valid keypress
             xval := (xval*24)/10                             ' 0-240, use portrait mode but it doesn't matter  
             yval := (yval*32)/10
             if xval>143 and xval <199 and yval >280 and yval <320
               synth.stop                                     ' close down the synthesizer
               return
             if xval >143 and xval <199 and yval > 240 and yval < 275 ' portamento switch
               tch.SelectMemGroup
               !portsw                                      ' change status
               if portsw
                     tch.DrawBMPRam(4,148,241)              ' switch on 
                     synth.noteOn(30, 19, 60, 12, 3, 6)                             ' turn on a note, next notes slide to this 
               else      
                     tch.DrawBMPRam(3,148,241)              ' switch off
                     synth.noteOff(18)                                              ' turn off any portamento
               tch.pause1ms(250) ' debounce delay  
               tch.SelectSPIGroup
             if xval >132 and xval <202 and yval >9 and yval <244                   ' one of the 5 sliders
               case yval
                 9..9+34:   DecRate := ReadSlider(xval,1)                             ' move the slider and scale value
                 53..53+34: SusLevel := ReadSlider(xval,2)     
                 88..88+34: PWinit := ReadSlider(xval,3)
                 124..124+34:PWMRate := ReadSlider(xval,4)
                 162..162+34:Filter := ReadSlider(xval,5)
                 210..210+34:Portamento := ReadSlider(xval,6)
             if xval < 53                                                           ' white keys     
              case yval                                     
                 0..23 : note := 20                              
                 24..56 : note := 22
                 57..89: note := 24
                 90..119 : note := 25
                 120..148: note := 27  
                 149..177: note := 29  
                 178..207: note := 31  
                 208..238: note := 32  
                 239..266: note := 34  
                 267..297: note := 36  
                 298..320: note := 37
             if (xval > 54) and (xval < 118)                     ' black keys a little bit wider so can play them
               case yval
                 10..44: note := 21  
                 47..77: note := 23
                 102..131: note := 26  
                 133..162: note := 28  
                 166..193: note := 30  
                 221..250: note := 33  
                 255..284: note := 35
             if note <> 0                                                           ' play note
               if portsw                                              ' portamento switch
                  synth.slideToNote(note, portamento/16) 
               else
                 synth.pluck(note, decRate/12, susLevel/4, pwinit, pwmRate/6, filter/32)        ' do any scaling here, all values 0-255
               note := 0
    
    PUB SynthSlider(x,y,value)                              ' value is 0-255. assumes bitmaps in ram
        tch.DrawBMPRam(6,x,y)                               ' draw background
        tch.DrawBMPRam(5,x+((value*100)/450),y+5)           ' draw the knob
    
    PUB RefreshSliders | n
        repeat n from 1 to 6
          RedrawOneSlider(n)
    
    PUB ReadSlider(y,n)
        y := y - 132                                            ' origin of the slider is 132
        y := y*256                                              ' slider is 69 pixels so convert to 256   
        y := y / 69
        if y < 0                                                ' check bounds
          y := 0
        if y > 255
          y := 255
        tch.SelectMemGroup
        RedrawOneSlider(n)                                  ' redraw this slider
        tch.SelectSPIGroup 
        result := y                    
    
    PUB RedrawOneSlider(n)                                  ' n = 1,2,3,4,5,6
       case n
         1:SynthSlider(132,9,decRate)                           ' decay     
         2:SynthSlider(132,53,susLevel)                         ' sustain
         3:SynthSlider(132,88,pwinit)                           ' pwminit
         4:SynthSlider(132,124,pwmRate)                         ' pwmrate
         5:SynthSlider(132,162,filter)                          ' filter (0-12 so multiply by 21)
         6:SynthSlider(132,210,portamento)                       ' portamento 0 - 16
         
    ' ********************************** end synth routines ************************
    
    320 x 240 - 13K
Sign In or Register to comment.