Shop OBEX P1 Docs P2 Docs Learn Events
Karplus-Strong on the Propeller? - Page 5 — Parallax Forums

Karplus-Strong on the Propeller?

1235

Comments

  • jeff-ojeff-o Posts: 181
    edited 2011-05-27 20:18
    This is a really fun thread to follow! There better be a video demo when it's all over! ;)

    Glad you like it. And yeah, there will definitely be video and audio once this is all wrapped up!
  • jeff-ojeff-o Posts: 181
    edited 2011-05-27 23:49
    Power supply is built, but not yet tested. Oh, how I wish I had a variac so I could turn up the mains voltage gradually! Will report back tomorrow once I, you know, sleep...
  • jeff-ojeff-o Posts: 181
    edited 2011-05-28 07:50
    I think we've got a winner here! I plugged it in this morning (picture me standing as far back as possible, safety glasses on, ready to yank the cord...) and it didn't blow up! Not only that but the power rails seem to be nice and steady where they should be. I haven't had a chance to fully test it yet, but a quick check on my scope showed very little noise and no periodic waveforms or ripple. I guess I'll know for sure when I use it to power the guitar!
  • HannoHanno Posts: 1,130
    edited 2011-05-29 19:16
    Please show a video! I demoed Karplus-Strong on a TBot in front of 100+ HBRC hobbyists at Google headquarters. Very nice sound compared to the sine and square wave tones other robots have played for the last 50 years.
    Hanno
  • jeff-ojeff-o Posts: 181
    edited 2011-05-29 19:21
    Hanno wrote: »
    Please show a video! I demoed Karplus-Strong on a TBot in front of 100+ HBRC hobbyists at Google headquarters. Very nice sound compared to the sine and square wave tones other robots have played for the last 50 years.
    Hanno

    Will do, I just need to get my new power supply up and running. Well, it's running, but I need to stuff it into a case so that it's safe to use.
  • jeff-ojeff-o Posts: 181
    edited 2011-05-31 18:19
    OK, I finally hooked up my new power supply in a somewhat permanent fashion. OK, it's safe - screwed onto a chunk of wood. Still have to find a case for it. Anyway, here are some waveforms for the three output voltages. As you can see, I've managed a nice clean 20mVp-p ripple on each line, which translates into zero noise and hum at the output! Argh, still kicking myself for not doing this ages ago, but at least I've learned not to trust switching power supplies when it comes to audio.

    -5V line:
    _5V_POWER.bmp

    +3.3V line:
    3_3V_POWER.bmp

    +5V line:
    5V_POWER.bmp

    So tonight I'll be putting my guitar back together again so I can continue with the software work. Feels nice to be getting things accomplished!
  • lonesocklonesock Posts: 917
    edited 2011-05-31 19:07
    Great progress! I always look forward to your updates.

    Jonathan
  • LawsonLawson Posts: 870
    edited 2011-05-31 19:54
    jeff-o wrote: »
    OK, I finally hooked up my new power supply in a somewhat permanent fashion. OK, it's safe - screwed onto a chunk of wood. Still have to find a case for it. Anyway, here are some waveforms for the three output voltages. As you can see, I've managed a nice clean 20mVp-p ripple on each line, which translates into zero noise and hum at the output! Argh, still kicking myself for not doing this ages ago, but at least I've learned not to trust switching power supplies when it comes to audio.

    -5V line:
    _5V_POWER.bmp

    +3.3V line:
    3_3V_POWER.bmp

    +5V line:
    5V_POWER.bmp

    So tonight I'll be putting my guitar back together again so I can continue with the software work. Feels nice to be getting things accomplished!

    Do you have new florescent lights in your shop? LCD back lights can also sit in the ~100KHz range. The 1GHz scope at work has a 105KHz brightness ripple in it's back light. I put that flicker to good use testing some amplified photo-diodes that needed at least 100kHz bandwidth. THAT "quick" project was a crash course in low noise Op-amp design! 147KHz is a high enough frequency to couple into a scope's ground wire, have you looked at what the scope measures with the ground wire hooked to the tip? Your linear regulators may be performing better that the scope screen shots show.

    Otherwise, I'll re-iterate that I think you could have gotten away with just using a linear regulator for the 3.3 volt rail. The 3.3 volt rail IS functioning as one reference voltage for the PWM DAC, so in retrospect its fairly obvious that it needs to be clean :p. (the other reference for the DAC is ground) Also, the couple tests done with the output filters powered and the string output stopped, show that the output op-amps can reject the level of ripple the PC supply had on the +5 and - 5 rails.

    Lawson
  • jeff-ojeff-o Posts: 181
    edited 2011-05-31 20:23
    Yep, there's a fluorescent work light directly above, plugged into the same circuit. The room lights are fluorescent as well. I'll measure again with the lights off!

    A linear regulator is what I used for all three voltages. 7805, 7905 and an LM317 for the 3.3V line. Oh, and some huge filter caps. Perhaps if I get a chance I'll hook up both supplies to see if it was the 3 or 5 volt line, but what you said makes sense - a ripple would affect the PWM DAC, and if the signal were within the voltage rails of the op amps then the signal would remain unaffected.

    I suppose in the end I wanted to design a dedicated power supply anyway. Once I publish plans (?) I want others to be able to grab off the shelf parts, rather than hack a computer power supply.

    Well
  • prof_brainoprof_braino Posts: 4,313
    edited 2011-06-01 04:44
    jeff-o wrote: »
    .... I want others to be able to grab off the shelf parts, rather than hack a computer power supply.

    Much appreciated!
  • jeff-ojeff-o Posts: 181
    edited 2011-06-02 12:27
    I got started on my menu system today (as in, after midnight...) The guitar features a 4x20 character LCD screen, controlled by a rotary encoder with a built-in switch. The user presses the dial to bring up the calibration menu, then can scroll through a number of tuning presets. The most difficult part so far is getting the encoder input to work properly. The official Parallax code works best of all the objects on the OBEX, but it still counts two "ticks" for each detent on the encoder. That would be fine if I could get away with simply dividing the count by two, but sometimes it only counts one tick, or three, so it's not so simple. Perhaps I'll have to work a modulo in there to determine if the Delta is an even number or not. However I end up doing it, I want a positive or negative integer that corresponds to how many detents the user felt when they turned the knob, and have that move a cursor on the screen. Hopefully it'll be up and running tonight and I can start loading in different guitar tunings.
  • jeff-ojeff-o Posts: 181
    edited 2011-06-02 22:16
    Rotary Encoder and basic menu are working. I was having a lot of trouble with it at the start; sometimes it would work and sometimes not. Turns out I had a bad wire leading up to the rotary encoder, so that only one of the pins was reliably switching. That set me back another evening, but oh well. At least I found a clever way (for me, anyway...) to switch menu positions through all this troubleshooting.

    I guess tomorrow night I'll start with the tuning menus.
  • jeff-ojeff-o Posts: 181
    edited 2011-06-05 20:49
    Finished up the power supply tonight. It now has a shiny new case that is roughly 1.25 million times better than the old one. Check it:

    DSC_4682.jpg
    DSC_4683.jpg


    In case it's a little hard to make out, I cut the vent holes in the shape of an ionizing radiation (nuke) symbol. The holes are covered in screen mesh (cut from an old screen window!), and backlit by a colour-changing LED. I cut the holes using a drill press and my trusty scroll saw. The whole thing is painted with Krylon spray paint.

    Overkill? Perhaps. But you know what they say, if you're gonna do something......
    1024 x 681 - 73K
    1024 x 681 - 75K
  • jeff-ojeff-o Posts: 181
    edited 2011-06-05 23:02
    Success! I managed to get my tuning-selection menu working. Right now the user is able to select from one of 15 different guitar tunings; three from a regular guitar (four of the six strings) and the rest are bass guitar tunings. The next step is to add a "custom tuning" screen where the user can select any open string frequency for each string, then save it to memory. I used a 64k EEPROM so there's lots of room to store custom tunings. Well, that's the plan, anyway. For the first release the guitar will simply remember which tuning it was set to the last time it was used.
  • Ahle2Ahle2 Posts: 1,179
    edited 2011-06-06 01:56
    When will you upload a video to show off this great project ?
  • jeff-ojeff-o Posts: 181
    edited 2011-06-06 05:53
    Ahle2 wrote: »
    When will you upload a video to show off this great project ?

    When it's done! My plan is to release full build instructions on Instructables, and I don't want to post a video on YouTube until those instructions are up. Otherwise, I'll have thousands (a guy can dream!) of requests from people who want to know where I got it, how to make one, how much I'd be willing to sell it for, etc.etc. So don't worry - audio and video are planned and coming, but the timing is carefully planned as well.
  • jeff-ojeff-o Posts: 181
    edited 2011-06-09 08:01
    After much tinkering, I finally finished the menu system for my laser guitar. The user is able to enter a Tuning menu, where they can choose from a number of different pre-set guitar tunings, or they can dial in a custom tuning. The tuning values are then used in the main program to change the pitch of the string. I'll also tack on some code that saves the current tunings into EEPROM memory.

    The next step is to integrate all that code into my main program.

    After that, the last thing I need to do is to build a fret position calibration program. The membrane potentiometers don't all measure alike even though the positions are the same, so a calibration routine is required to ensure that all the fret positions register properly.

    I've got plans for features beyond this, but I want to get the guitar to this point first.
  • jeff-ojeff-o Posts: 181
    edited 2011-06-11 05:37
    Calibration program is done! I've created a companion program whose purpose is to fill the EEPROM with tuning values and calibrate the membrane potentiometer strings. I'm using memory management to store the values in the top half of a 64K EEPROM. It took a while to get it running properly (especially storing arrays) but I figured it out eventually.

    So, now I just need a few tweaks to my main program, and I should be good to go...
  • StefanL38StefanL38 Posts: 2,292
    edited 2011-06-11 09:03
    Hi Jeff-o,

    have you ever thought about connecting your laser-guitar to the Coyote-1 OpenStomp-pedal?
    http://www.openstomp.com/wiki/index.php?title=Main_Page

    I guess this creates the most quadrature-propellerised sounds you have ever heard :-)

    best regards

    Stefan
  • jeff-ojeff-o Posts: 181
    edited 2011-06-11 10:11
    StefanL38 wrote: »
    Hi Jeff-o,

    have you ever thought about connecting your laser-guitar to the Coyote-1 OpenStomp-pedal?
    http://www.openstomp.com/wiki/index.php?title=Main_Page

    I guess this creates the most quadrature-propellerised sounds you have ever heard :-)

    best regards

    Stefan

    Sure have! It would work great with the OpenStomp, or any other pedal. The output is a standard 1/4" jack.
  • jeff-ojeff-o Posts: 181
    edited 2011-06-11 12:42
    The full program is nearly complete! But there's a problem: it's too big. Time to make things more efficient.
  • jeff-ojeff-o Posts: 181
    edited 2011-06-12 06:39
    700 longs down, 122 to go... Oy.
  • John A. ZoidbergJohn A. Zoidberg Posts: 514
    edited 2011-06-12 06:40
    We would love to hear the sound of music, and the music of sound from the Propeller! :)
  • lonesocklonesock Posts: 917
    edited 2011-06-12 16:39
    BTW, you might want to hack the code so each string's KS code has a buffer just large enough to work with the lowest pitch that string will play. And since you are using a different cog per string, with its own DAC output, you could even have all strings use a fairly small buffer, and just change the sampling rate for each object.

    Jonathan
  • jeff-ojeff-o Posts: 181
    edited 2011-06-12 17:46
    I'll start by turning down the sampling rate. It's at 96k right now, so I'll make it 48k and see how far that gets me.
  • jeff-ojeff-o Posts: 181
    edited 2011-06-13 08:37
    Turns out I didn't need to turn down the sampling rate after all. Moving all my strings to the upper 32k of EEPROM space cleared up enough space.
  • jeff-ojeff-o Posts: 181
    edited 2011-06-16 05:03
    Once I added the additional feature I needed I ran out of space again. Reducing the buffer from 1680 seems to have a negative effect on the strings (the pitch changes) - even a setting of 1500 messes them up. I'll post the code in the other thread I started regarding reducing the size of my program, maybe some smart folks can help me out and boost the efficiency of my program a bit!
  • lonesocklonesock Posts: 917
    edited 2011-06-16 09:17
    If you reduce the sample rate by 1/2, I would expect that you could also reduce the KS buffer size by 1/2 (and by "expect", I mean it works for me, not that that helps you any [8^). I noticed in your code from the other thread that in the function "MULTI_KS" (called from _main) you pass in the sample rate, but in "start_string" (called from statetune) you use the constant sr, which is set to 96000; is it possible that that is causing a mixup when you try the lower samplig rate?

    Jonathan
  • jeff-ojeff-o Posts: 181
    edited 2011-06-16 10:04
    I'll try again tonight, and make sure that both the main KS.spin and my multiKS are both using 48k throughout. start_string was added so that I could restart the strings after retuning them, and I was always careful to restart them with the existing sample rate. But maybe I messed up. And maybe I should remove that ability completely, and just have the sample rate fixed at 48k from now on...
  • jeff-ojeff-o Posts: 181
    edited 2011-07-06 09:22
    It's been a while but I thought I'd update everyone on the progress I've made with my Karplus-Strong wielding laser guitar.

    First off, I fixed the memory issues I was having, both in running out of room on the Propeller and in storing variables between power cycles. Lots of head-scratching, testing and discussion led me to using a new, compatible EEPROM chip.

    Right now, the guitar plays like a real guitar. Pluck the strings, hold the frets, and you get a response like a real guitar. Palm mute is implemented as well as basic control over volume and sustain. And of course, the ability to quickly switch between different guitar tunings through a simple menu system. You can even dial in your own custom tuning.

    So really, at this point it's very nearly done. There is just one thing left to add, and that is pitch bending. In the implementation I have now, the player may change the pitch in one-note increments. Unfortunately that causes somewhat of a "staircase" effect, much like running one's finger along the fretboard. Once I get the pitch bending solved, I will consider development on this version to be complete.

    I can't wait to post build info, pictures and video to the 'net!
Sign In or Register to comment.