fluid-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [fluid-dev] A new program using FluidSynth


From: Josh Green
Subject: Re: [fluid-dev] A new program using FluidSynth
Date: Thu, 19 Apr 2007 18:19:41 +0200

Hello Zachary,

On Mon, 2007-04-16 at 14:25 -0400, Zachary Northrup wrote:
> Hello,
>  
> It says on the FluidSynth homepage to email this list with any new
> programs using FluidSynth. I've been working on a program called
> Z-Maestro which is basically like Apple Garageband for Windows. It
> offers some functionality that Garageband lacks, and lacks some
> functionality that Garageband gives, but it generally works pretty
> well. I'm going to be releasing RC1 soon, so I though you might want
> to take a look at it. My website is at http://www.z-sys.org/, and the
> product page for it is at http://www.z-sys.org/zmaestro.aspx. Like I
> said, it's for Windows, and it needs the .NET framework 2.0 to be
> installed. That's right, it is managed code running FluidSynth. In
> fact, Z-Maestro is almost completely programmed in VB.NET. I never
> thought I would get it working.

I added a link to your application on the new FluidSynth Trac Wiki.  The
FluidSynth web site isn't redirecting yet to the Wiki, but will be once
I get subversion working.  Feel free to edit the entry for you
application if you'd like (requires registering an account to keep out
the spam).

http://fluidsynth.resonance.org/trac/wiki/Applications

> Another problem is that (mainly due to my lack of experience in native
> C++/C and the interop required between managed and native code) I
> can't figure out how some functions are used and how I can marshal
> them to managed code. The one function I am most anxious to figure out
> how to translate is the fluid_synth_write_s16 function for recording
> output. I'd like to see some simple examples of how it's used. The
> documentation only says that it fills two buffers with left and right
> audio info. Does this mean that FluidSynth is keeping a buffer
> in-memory of all audio?

I forgot to reply to this.  Here is a description of the
fluid_synth_write_s16 function:

int
fluid_synth_write_s16(fluid_synth_t* synth, int len,
                     void* lout, int loff, int lincr,
                     void* rout, int roff, int rincr)

len:   Number of frames to write (2 stereo samples = 1 frame)

lout:  Caller supplied buffer to store left channel samples to
loff:  Index offset to start at in lout buffer
lincr: Index increment value to use when storing samples to lout buffer

rout:  Caller supplied buffer to store right channel samples to
roff:  Index offset to start at in rout buffer
rincr: Index increment value to use when storing samples to rout buffer

So to answer your question, yes the buffers are supplied by the caller.
The reason for all the variables, rather than just len and a buf
pointer, is for added flexibility.  In particular, the stereo audio can
be stored interleaved to a single buffer or stored to separate buffers.

To write interleaved audio to a buffer:

int len = 1024;
char *buf;

buf = malloc (len * 2 * 2);     // 16 bit samples (2 bytes) * stereo

fluid_synth_write_s16 (synth, len, buf, 0, 2, buf, 1, 2);


To write to separate buffers:

int len = 1024;
char *lbuf, *rbuf;

lbuf = malloc (len * 2);
rbuf = malloc (len * 2);

fluid_synth_write_s16 (synth, len, lbuf, 0, 1, rbuf, 0, 1);


Hope that helps explain it.  Let me know if you are still having trouble
understanding.

>  
> Thanks for creating such a useful synth.


Peter Hanappe (the original author) deserves most of the thanks, I'm
just trying to maintain it properly ;)


>  
> Zachary Northrup
> http://www.z-sys.org/

Best regards,
        Josh Green






reply via email to

[Prev in Thread] Current Thread [Next in Thread]