electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Links  |  Store
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks GalleryGallery 
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
 Forum index » DIY Hardware and Software » ChucK programming language
Does ChucK Play the Piano?
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [17 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
Inventor



Joined: Oct 13, 2007
Posts: 1168
Location: Florida, USA
Audio files: 50

PostPosted: Thu Mar 13, 2008 8:16 pm    Post subject: Does ChucK Play the Piano?
Subject description: How do I make a piano in ChucK?
Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website
kijjaz



Joined: Sep 20, 2004
Posts: 452
Location: bangkok, thailand
Audio files: 2

PostPosted: Thu Mar 13, 2008 9:20 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Inventor



Joined: Oct 13, 2007
Posts: 1168
Location: Florida, USA
Audio files: 50

PostPosted: Thu Mar 13, 2008 9:42 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website
kijjaz



Joined: Sep 20, 2004
Posts: 452
Location: bangkok, thailand
Audio files: 2

PostPosted: Fri Mar 14, 2008 1:02 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Frostburn



Joined: Dec 12, 2007
Posts: 212
Location: Finland
Audio files: 7

PostPosted: Fri Mar 14, 2008 5:50 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message
Inventor



Joined: Oct 13, 2007
Posts: 1168
Location: Florida, USA
Audio files: 50

PostPosted: Fri Mar 14, 2008 8:15 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website
Frostburn



Joined: Dec 12, 2007
Posts: 212
Location: Finland
Audio files: 7

PostPosted: Fri Mar 14, 2008 8:30 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message
Inventor



Joined: Oct 13, 2007
Posts: 1168
Location: Florida, USA
Audio files: 50

PostPosted: Fri Mar 14, 2008 9:04 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website
Frostburn



Joined: Dec 12, 2007
Posts: 212
Location: Finland
Audio files: 7

PostPosted: Fri Mar 14, 2008 12:19 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message
Inventor



Joined: Oct 13, 2007
Posts: 1168
Location: Florida, USA
Audio files: 50

PostPosted: Fri Mar 14, 2008 12:43 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website
Frostburn



Joined: Dec 12, 2007
Posts: 212
Location: Finland
Audio files: 7

PostPosted: Fri Mar 14, 2008 12:56 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message
radarsat1



Joined: Mar 14, 2008
Posts: 14
Location: Montreal

PostPosted: Fri Mar 14, 2008 12:59 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message
Inventor



Joined: Oct 13, 2007
Posts: 1168
Location: Florida, USA
Audio files: 50

PostPosted: Fri Mar 14, 2008 1:27 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website
radarsat1



Joined: Mar 14, 2008
Posts: 14
Location: Montreal

PostPosted: Fri Mar 14, 2008 4:59 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message
Frostburn



Joined: Dec 12, 2007
Posts: 212
Location: Finland
Audio files: 7

PostPosted: Sat Mar 22, 2008 5:25 am    Post subject: Reply with quote  Mark this post and the followings unread

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? Smile

_________________
To boldly go where no man has bothered to go before.
Back to top
View user's profile Send private message
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 6248
Location: The Hague, NL
G2 patch files: 3

PostPosted: Sat Mar 22, 2008 7:07 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website
radarsat1



Joined: Mar 14, 2008
Posts: 14
Location: Montreal

PostPosted: Sat Mar 22, 2008 11:03 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [17 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » ChucK programming language
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum

Please support our site. If you click through and buy from
our affiliate partners, we earn a small commission.


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003, 2004, 2005, 2006 and 2007 by electro-music.com