iiwusynth-devel
[Top][All Lists]
Advanced

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

[iiwusynth-devel] Re: Swami: No sound in iiwusynth


From: M. Nentwig
Subject: [iiwusynth-devel] Re: Swami: No sound in iiwusynth
Date: Thu, 20 Jun 2002 17:49:04 +0300

Hei,

(...)
> Something I was wondering about. To split out the controller and flags

> fields for iiwusynth I'm not using the enumerations directly, but
> instead shifting the flags by 8 and then or'ing the CC flag in, I'm
> assuming the iiwusynth modulator enumerations probably wont change,
> right?

Well, if you produce the same value as |ing the constants from
iiwusynth.h, then I'd guess that it works. I don't think that the
constants will change, but the code might be more readable. In
iiwu_defsfont.c (see end of mail), many lines of code are just to make
it easier to read, they don't do anything (after preprocessing it
results in 'flags |=0').

> Concerning not requiring the default modulators. I don't see
> how this is
> going to work right. What happens if there is a generator at
> the preset
> level that is identical to a default modulator? In this case it should

> be combined with the default modulator and the amount fields added. I
> guess I could use IIWU_VOICE_ADD for preset modulators but I
> would then
> need to put this in my generic layering routine (calls a callback
> routine for each voice in a SoundFont item) which doesn't
> make sense.

Now I'll have to correct something I wrote earlier. To turn off a
default modulator, you can either create a modulator with amount=0 on
instrument level (global zone or inst. zone), or use a modulator with
the negative amount on instrument level. The first option sounds more
attractive to me.
But this is not my invention, this is the mechanism described in section
9.5 of our favourite standards document :-)

>From the 'swami' perspective you don't have to worry about creating the
default modulators for iiwusynth; they are there as soon as you allocate
a new voice - it comes preinitialized with all default modulators. Of
course you could use tricks on the voice to get rid of them, but
creating a new modulator with amount=0 will (should...) also work on
other 2.1 compatible synths.

> I suppose if this makes the most sense for iiwusynth, I could ditch my

> generic foreach layer routine and just write a custom one with
> IIWU_VOICE_ADD for presets, but this seems messy.

Here I'm not 100 % sure if I understand you correctly. But I think this
is just what iiwu_defsfont.c does: Instrument level and preset level are
handled separately, because the rules are different.
My (=iiwusynth's) interpretation of the standard is in
iiwu_defpreset_noteon.

> I guess just doing things the way they are just means that
> there is the
> added overhead of setting the default modulators twice, perhaps this
> isn't really an issue then.

That can't be avoided (when sticking with the standard): Once the
default modulator is set when allocating the voice, only to have it
overwritten with an empty modulator directly afterwards. And if the
sound font contains an 'identical' modulator with different amount...
let's set it a third time :-)
It's likely that there are a couple of bugs in iiwusynth related to
modulators (maybe conceptual problems, if we are unlucky), because
testing was limited to default modulators and a limited selection of
examples so far.

> Cheers!
>  Josh
>
> P.S My changes aren't in CVS yet, and I don't think they will be for a

> couple days (until I get internet access again).
>

Cheers

Markus





>From iiwu_defsfont.c, concerning the flags
  /* Import the modulators (only SF2.1 and higher) */
  for (count = 0, r = sfzone->mod; r != NULL; count++) {

    SFMod* mod_src = (SFMod *)r->data;
    iiwu_mod_t * mod_dest = iiwu_mod_new();
    int type;

    if (mod_dest == NULL){
      return IIWU_FAILED;
    };
    mod_dest->next = NULL; /* pointer to next modulator, this is the end
of the list now.*/

    /* *** Amount *** */
    mod_dest->amount = mod_src->amount;

    /* *** Source *** */
    mod_dest->src1 = mod_src->src & 127; /* index of source 1, seven-bit
value, SF2.01 section 8.2, page 50 */
    mod_dest->flags1 = 0;

    /* Bit 7: CC flag SF 2.01 section 8.2.1 page 50*/
    if (mod_src->src & (1<<7)){
      mod_dest->flags1 |= IIWU_MOD_CC;
    } else {
      mod_dest->flags1 |= IIWU_MOD_GC;
    };

    /* Bit 8: D flag SF 2.01 section 8.2.2 page 51*/
    if (mod_src->src & (1<<8)){
      mod_dest->flags1 |= IIWU_MOD_NEGATIVE;
    } else {
      mod_dest->flags1 |= IIWU_MOD_POSITIVE;
    };

    /* Bit 9: P flag SF 2.01 section 8.2.3 page 51*/
    if (mod_src->src & (1<<9)){
      mod_dest->flags1 |= IIWU_MOD_BIPOLAR;
    } else {
      mod_dest->flags1 |= IIWU_MOD_UNIPOLAR;
    };

    /* modulator source types: SF2.01 section 8.2.1 page 52 */
    type=(mod_src->src) >> 10;
    type &= 63; /* type is a 6-bit value */
    if (type == 0){
      mod_dest->flags1 |= IIWU_MOD_LINEAR;
    } else if (type == 1){
      mod_dest->flags1 |= IIWU_MOD_CONCAVE;
    } else if (type == 2){
      mod_dest->flags1 |= IIWU_MOD_CONVEX;
    } else if (type == 3){
      mod_dest->flags1 |= IIWU_MOD_SWITCH;
    } else {
      /* This shouldn't happen - unknown type!
       * Deactivate the modulator by setting the amount to 0. */
      mod_dest->amount=0;
    };

    /* *** Dest *** */
    mod_dest->dest = mod_src->dest; /* index of controlled generator */

    /* *** Amount source *** */
    mod_dest->src2 = mod_src->amtsrc & 127; /* index of source 2,
seven-bit value, SF2.01 section 8.2, p.50 */
    type = (mod_src->amtsrc) >> 10;
    type &= 63; /* type is a 6-bit value */

    mod_dest->flags2 = 0;

    /* Bit 7: CC flag SF 2.01 section 8.2.1 page 50*/
    if (mod_src->amtsrc & (1<<7)){
      mod_dest->flags1 |= IIWU_MOD_CC;
    } else {
      mod_dest->flags1 |= IIWU_MOD_GC;
    };

    /* Bit 8: D flag SF 2.01 section 8.2.2 page 51*/
    if (mod_src->amtsrc & (1<<8)){
      mod_dest->flags1 |= IIWU_MOD_NEGATIVE;
    } else {
      mod_dest->flags1 |= IIWU_MOD_POSITIVE;
    };

    /* Bit 9: P flag SF 2.01 section 8.2.3 page 51*/
    if (mod_src->amtsrc & (1<<9)){
      mod_dest->flags1 |= IIWU_MOD_BIPOLAR;
    } else {
      mod_dest->flags1 |= IIWU_MOD_UNIPOLAR;
    };
   etc etc






reply via email to

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