[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[iiwusynth-devel] Exclusive class and float-limiter
From: |
M. Nentwig |
Subject: |
[iiwusynth-devel] Exclusive class and float-limiter |
Date: |
Tue, 07 May 2002 18:54:47 +0300 |
Hello,
I have implemented the exclusive class function ('an open hi-hat sound
terminates a closed-hi-hat sound'). Further, I have removed the limiter
for float-output, which took me so much effort to implement only a week
ago (four lines of beautifully handcrafted code, although completely
braindead :-)
I can put this on CVS soon, up until then you can download the whole
iiwusynth folder here:
http://prdownloads.sourceforge.net/millisampler/iiwu_12_tar.bz2
Now there is a new Iiwusynth API function to terminate voices on a given
channel, depending on exclusive class. iiwu_defsfont.c will then call it
during the voice setup. It's somehow on one level with 'allocate_voice'.
But during 'allocate_voice', the exclusive class is not yet known, so
this had to be put into an own function.
Maybe this should be made more generic, i.e. 'postprocess_voice' or the
like. Peter?
Below is a diff, let's hope the linebreaks are not mangled this time.
Cheers
Markus
diff -ur iiwusynth/ChangeLog iiwu_12/iiwusynth/ChangeLog
--- iiwusynth/ChangeLog Wed May 1 19:05:40 2002
+++ iiwu_12/iiwusynth/ChangeLog Mon May 6 22:49:50 2002
@@ -1,3 +1,10 @@
+2002-05-06 Markus Nentwig <address@hidden>
+
+ * src/iiwu_synth.c (iiwu_synth_write_float): Removed signal limiting
to [-1..1] in iiwu_synth_write_float
+ * src/iiwu_defsfont.c (iiwu_defpreset_noteon): Added exclusive class
support
+ * src/iiwusynth.h (iiwu_synth_terminate_exclusive_class): added to
API.
+ * src/iiwu_synth.c (iiwu_synth_terminate_exclusive_class):
+
2002-04-30 Markus Nentwig <address@hidden>
* src: Added iiwu_LADSPA.c, iiwu_LADSPA.h (support for LADSPA effect
plugins).
diff -ur iiwusynth/src/iiwu_defsfont.c
iiwu_12/iiwusynth/src/iiwu_defsfont.c
--- iiwusynth/src/iiwu_defsfont.c Wed May 1 18:40:49 2002
+++ iiwu_12/iiwusynth/src/iiwu_defsfont.c Mon May 6 22:44:35 2002
@@ -735,6 +735,16 @@
};
};
+ /* Process exclusive groups
+ * SF2.01 page 47, section 8.1.2 item 57
+ * If the instrument has a generator for 'exclusive class', then
triggering
+ * it will kill all other voices on the same channel (same preset).
+ * Example: percussion / drums (Hi-hat,...)
+ */
+ if ((int)(voice->gen[GEN_EXCLUSIVECLASS].val)!=0){
+ iiwu_synth_terminate_exclusive_class(synth, chan,
(int)(voice->gen[GEN_EXCLUSIVECLASS].val));
+ };
+
/* add the synthesis process to the synthesis loop. */
iiwu_voice_start(voice);
}
diff -ur iiwusynth/src/iiwu_synth.c iiwu_12/iiwusynth/src/iiwu_synth.c
--- iiwusynth/src/iiwu_synth.c Wed May 1 18:40:49 2002
+++ iiwu_12/iiwusynth/src/iiwu_synth.c Mon May 6 22:48:31 2002
@@ -677,6 +677,28 @@
}
/*
+ * iiwu_synth_terminate_exclusive_class
+ */
+void
+iiwu_synth_terminate_exclusive_class(iiwu_synth_t* synth, int chan, int
exclusive_class){
+ /* Purpose:
+ * Terminates all voices on chan, which belongs to exclusive_class.
+ * SF2.01 page 47, section 8.1.2 item 57
+ */
+ int i;
+ iiwu_voice_t* voice;
+ if (exclusive_class==0){return;};
+ for (i = 0; i < synth->nvoice; i++){
+ voice = synth->voice[i];
+ if ((_PLAYING(voice)) && (voice->chan == chan) &&
((int)(voice->gen[GEN_EXCLUSIVECLASS].val) == exclusive_class)){
+ // Fixme: this cuts off the voice.
+ // A better solution will be noteoff and setting
volenv_data[5].incr high enough.
+ iiwu_voice_off(voice);
+ }
+ }
+}
+
+/*
* iiwu_synth_damp_voices
*/
int
@@ -967,12 +989,6 @@
iiwu_synth_one_block(synth);
l = 0;
}
-
- /* Clip to maximum range */
- if (left_in[l] > 1.f) {left_in[l] = 1.f;};
- if (left_in[l] < -1.f) {left_in[l] = -1.f;};
- if (right_in[l] > 1.f) {right_in[l] = 1.f;};
- if (right_in[l] < -1.f) {right_in[l] = -1.f;};
left_out[j] = (float) left_in[l];
right_out[k] = (float) right_in[l];
diff -ur iiwusynth/src/iiwusynth.h iiwu_12/iiwusynth/src/iiwusynth.h
--- iiwusynth/src/iiwusynth.h Thu Apr 11 01:22:14 2002
+++ iiwu_12/iiwusynth/src/iiwusynth.h Mon May 6 22:04:28 2002
@@ -392,6 +392,9 @@
soundfont's preset in responce to a noteon event */
IIWU_SYNTH_API iiwu_voice_t* iiwu_synth_alloc_voice(iiwu_synth_t*
synth, iiwu_sample_t* sample, int channum, int key, int vel);
+ /** Terminate all voices on a given channel belonging to a given
exclusive class. This function is called by a
+ soundfont's preset in responce to a noteon event */
+IIWU_SYNTH_API void iiwu_synth_terminate_exclusive_class(iiwu_synth_t*
synth, int chan, int exclusive_class);
/*
* The interface to the synthesizer's voices
- [iiwusynth-devel] Exclusive class and float-limiter,
M. Nentwig <=