| Author |
Message |
Inventor

Joined: Oct 13, 2007 Posts: 1153 Location: Florida, USA
Audio files: 50
|
Posted: Thu Mar 13, 2008 8:16 pm Post subject:
Does ChucK Play the Piano? Subject description: How do I make a piano in ChucK? |
 |
|
| For my relaxation series and maybe even for the rock, I'd like to add some piano. What's the best instrument / ugen for this? |
|
|
Back to top
|
|
 |
kijjaz

Joined: Sep 20, 2004 Posts: 452 Location: bangkok, thailand
Audio files: 2
|
Posted: Thu Mar 13, 2008 9:20 pm Post subject:
|
 |
|
Rhodey and Wurly in the StkInstruments sound quite real.
But Wooden Piano..? hmm..
I'm thinking about using some digital waveguide synthesis for the piano. |
|
|
Back to top
|
|
 |
Inventor

Joined: Oct 13, 2007 Posts: 1153 Location: Florida, USA
Audio files: 50
|
Posted: Thu Mar 13, 2008 9:42 pm Post subject:
|
 |
|
| You know digital waveguide synthesis, kijjaz? That's way over my head. Your ChucK powers are strong indeed. I'll check out Wurly and Rhodey for Guitar Lab, thanks. |
|
|
Back to top
|
|
 |
kijjaz

Joined: Sep 20, 2004 Posts: 452 Location: bangkok, thailand
Audio files: 2
|
Posted: Fri Mar 14, 2008 1:02 am Post subject:
|
 |
|
Hmm.. i'm not that strong at doing something deep heheh -_-"..
(but i am crazy)
I'm going to work on some general digital waveguide models.
Maybe I'll start with a class that manipulate an array of floats that'd be used for the models i'll come up. |
|
|
Back to top
|
|
 |
Frostburn

Joined: Dec 12, 2007 Posts: 211 Location: Finland
Audio files: 7
|
Posted: Fri Mar 14, 2008 5:50 am Post subject:
|
 |
|
http://ccrma.stanford.edu/~jos/wg.html has research papers on Digital Waveguide synthesis, including modeling the piano. Most of the models use a sampled or otherwise tabulated hammer impulses and it's not easy to make a realistic piano without them.
However the bulk of "synthesizer" pianos are just samplers and some of the soundfonts I've found aren't half bad. Maybe we/you/I could turn a free soundfont of choice to a class with SndBuf's in chuck. _________________ To boldly go where no man has bothered to go before. |
|
|
Back to top
|
|
 |
Inventor

Joined: Oct 13, 2007 Posts: 1153 Location: Florida, USA
Audio files: 50
|
Posted: Fri Mar 14, 2008 8:15 am Post subject:
|
 |
|
Wow, that seems to be a very well written set of documentation for digital waveguide synthesis. It is quite similar to the waveguide simulations that I did in college. Thanks for the reference, Frostburn.
Hmmm, so we must decide between samples and waveguides? Well, we are up against compute limits unless I can optimize the program somehow, so samples look nice. Then again, a wavegiude model could be quite efficient. I wonder about the situation of new notes striking while old notes are still resonating. The sequencer in Guitar Lab strikes a note every so many times per second, whether the previous note is finished or not.
To accommodate that might take an entire piano of waveguides, which would be too inefficient, then again, is SndBuff capable of dealing with overlapping samples?
I like the idea of keeping the project to a single file with no subdirectories for sound files, but if a zipped up directory is what we need, then I'll have to figure out how to make tar and gzip wrap them up into a single file for distribution (that's no problem).
I don't know, both solutions look equally menacing to me! haha! Would either one handle the overlapping notes issue better than the other? Perhaps the answer is to have both models in the program. |
|
|
Back to top
|
|
 |
Frostburn

Joined: Dec 12, 2007 Posts: 211 Location: Finland
Audio files: 7
|
Posted: Fri Mar 14, 2008 8:30 am Post subject:
|
 |
|
| Inventor wrote: | | I don't know, both solutions look equally menacing to me! haha! Would either one handle the overlapping notes issue better than the other? Perhaps the answer is to have both models in the program. |
A waveguide can in principle be online all the time and it doesn't care if it's playing a note or not when you feed in the next hammer impulse. Of course to limit the CPU strain the waveguide needs to be unchucked after it has finished playing ie. gone so quiet that you don't hear the click when you disconnect it.
A SndBuf on the other hand cannot deal with overlaps. But maybe two buffers per note is enough... that's 256 sample buffers for a MIDI piano (512 if we go stereo). Shouldn't be a problem because it should be possible to call sndbuf.read the first time the note is played. _________________ To boldly go where no man has bothered to go before. |
|
|
Back to top
|
|
 |
Inventor

Joined: Oct 13, 2007 Posts: 1153 Location: Florida, USA
Audio files: 50
|
Posted: Fri Mar 14, 2008 9:04 am Post subject:
|
 |
|
What the program does is it has a button for each instrument. When an instrument's button is toggled on, the instrument gets ChucKed up, and when it is toggled off, the instrument gets unChucKed. The SndBuf.read could be called at the button press moment, so no problem there. 256 of anything sounds like a lot, but maybe it's manageable, and we may as well just do mono since the rest of guitar lab is mono.
I guess we should try both models and see what happens, eh? |
|
|
Back to top
|
|
 |
Frostburn

Joined: Dec 12, 2007 Posts: 211 Location: Finland
Audio files: 7
|
Posted: Fri Mar 14, 2008 12:19 pm Post subject:
|
 |
|
Another option besides waveguides or samples is additive synthesis. That is controlling the spectrum in time with float functions. It's not as fast but it can still be done in real time with IFFT.
I'd start with the sampler but if I make it I will make it as an Instrument in my library. (I don't have a Mac so I can't run MAUI and coding for something I cannot debug would be a bit strange.)
WG and additive synthesis take a lot of skill if your goal is the piano. The instrument is only 300 years old and it is the product of great cratmanship and fine tuning. It's timbre is not easy to replicate but trying is always fun. :) _________________ To boldly go where no man has bothered to go before. |
|
|
Back to top
|
|
 |
Inventor

Joined: Oct 13, 2007 Posts: 1153 Location: Florida, USA
Audio files: 50
|
Posted: Fri Mar 14, 2008 12:43 pm Post subject:
|
 |
|
Oh, your instrument library sounds interesting, perhaps there are some other instruments in there that I could add to Guitar Lab. Maybe you've already got some goodies in there that are suitable for re-use.
The additive synthesis sounds neat, but how would we know what time-varying functions to apply to the IFFT to get a piano? |
|
|
Back to top
|
|
 |
Frostburn

Joined: Dec 12, 2007 Posts: 211 Location: Finland
Audio files: 7
|
Posted: Fri Mar 14, 2008 12:56 pm Post subject:
|
 |
|
| Inventor wrote: |
The additive synthesis sounds neat, but how would we know what time-varying functions to apply to the IFFT to get a piano? |
The same way we would know how to model the waveguide and the hammer impulse. Trial, error, more trial and error, looking at spectrograms of piano samples trying to figure out how the partials evolve in time, trying to figure out how to make a function out of that, trial, more error, ... , figuring it all out eventually, success.
| Inventor wrote: | Oh, your instrument library sounds interesting, perhaps there are some other instruments in there that I could add to Guitar Lab. Maybe you've already got some goodies in there that are suitable for re-use.
|
I got this killer (well it kills my CPU if nothing else) enharmonic additive synthesizer in the works but when I've done polishing things up I'll release a beta version and some documentation on how to use the instruments. They support note playing on arbitrary frequencies so they should be easy re-use. _________________ To boldly go where no man has bothered to go before. |
|
|
Back to top
|
|
 |
radarsat1
Joined: Mar 14, 2008 Posts: 14 Location: Montreal
|
Posted: Fri Mar 14, 2008 12:59 pm Post subject:
|
 |
|
hi,
maybe someone would be willing to port this to a ChucK Ugen. I wish I had time to do it myself but I don't. It's STK, so it should be fairly straightforward to port it.
http://www.music.mcgill.ca/~sinclair/content/stk_piano
cheers. |
|
|
Back to top
|
|
 |
Inventor

Joined: Oct 13, 2007 Posts: 1153 Location: Florida, USA
Audio files: 50
|
Posted: Fri Mar 14, 2008 1:27 pm Post subject:
|
 |
|
I skimmed through the pdf on that stk_piano model. I had no idea I was suggesting such a complex and difficult thing to do. Perhaps we can just borrow the hammer model from it, which is an impulse followed by low pass filters. Then maybe borrow some pieces of the waveguide stuff, and make a "piano-like" instrument.
Rather than painstakingly model all the characteristics of a real piano, we can just use a simple model to approximate it. This keeps the cpu usage low and the amount of effort low as well, while probably producing fairly good sound. |
|
|
Back to top
|
|
 |
radarsat1
Joined: Mar 14, 2008 Posts: 14 Location: Montreal
|
Posted: Fri Mar 14, 2008 4:59 pm Post subject:
|
 |
|
| well, my point was more that it's already done. but sure, feel free to pick it apart too if that's helpful. |
|
|
Back to top
|
|
 |
Frostburn

Joined: Dec 12, 2007 Posts: 211 Location: Finland
Audio files: 7
|
Posted: Sat Mar 22, 2008 5:25 am Post subject:
|
 |
|
I just tried the additive synthesis approach.
So far too thin.
A good grand really needs that internal reverbation to give all that space and brightness to the sound.
I skimmed through the pdf for Stk piano. Looking good. I still haven't tried it but if it sounds ok it would be worth the port.
Anyone with some stk experience and too much free time?  _________________ To boldly go where no man has bothered to go before. |
|
|
Back to top
|
|
 |
Kassen
Janitor


Joined: Jul 06, 2004 Posts: 6239 Location: The Hague, NL
G2 patch files: 3
|
Posted: Sat Mar 22, 2008 7:07 am Post subject:
|
 |
|
I'd go for parallel band-pass filters for the piano's internal reverberation, I think, but I have a soft-spot for modal synthesis anyway.
The internal reverberation makes a huge difference indeed, just for kicks add this to your favorite cheap toy piano sound;
http://www.pspaudioware.com/plugins/piano.html _________________ while(!machine.crash() ) <<<"all is well">>>; |
|
|
Back to top
|
|
 |
radarsat1
Joined: Mar 14, 2008 Posts: 14 Location: Montreal
|
Posted: Sat Mar 22, 2008 11:03 am Post subject:
|
 |
|
i just tested stkpiano since i haven't actually tried it in a while.
At the default settings there was some serious distortion in the output.
However, i tried with "./pianotest voices=1 buffersize=256" and it sounded fine, so I recommend those settings if you want to give it a try. I guess one bad thing about it is that it's not exactly optimally efficient. There are a lot of extra filters and things in there to make it sound marginally better that could probably be sacrificed for speed.
Who knows maybe in the summer I'll have time to do a port to ChucK, it would be great.. but I can't promise.
By the way if you haven't read the document... the gist of it is that it uses waveguides for notes lower than 88, and modal synthesis for the higher notes. It uses look-up tables for the non-linear velocity mapping. And there's a bunch of all-pass filters to model stiffness... it can be made to sound like a harpsichord if you turn this up. |
|
|
Back to top
|
|
 |
|