summaryrefslogtreecommitdiff
path: root/native/jni/midi-dssi/gnu_javax_sound_midi_dssi_DSSISynthesizer.c
blob: 55881bef88433943f7ca76444f65cb37d28f429f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
/* gnu_javax_sound_midi_dssi_DSSISynthesizer.c - DSSI Synth
   Copyright (C) 2005 Free Software Foundation, Inc.

This file is part of GNU Classpath.

GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
 
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING.  If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.

Linking this library statically or dynamically with other modules is
making a combined work based on this library.  Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.

As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module.  An independent module is a module which is not derived from
or based on this library.  If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so.  If you do not wish to do so, delete this
exception statement from your version. */

/* The original get_port_default() and set_control() routines were
 * copied from the DSSI source distribution and are covered by the
 * following copyright and license...
 *
 * Copyright 2004 Chris Cannam, Steve Harris and Sean Bolton.
 * 
 * Permission to use, copy, modify, distribute, and sell this software
 * for any purpose is hereby granted without fee, provided that the
 * above copyright notice and this permission notice are included in
 * all copies or substantial portions of the software.
 */

#include <config.h>
#include <gnu_javax_sound_midi_dssi_DSSISynthesizer.h> 
#include <math.h>

#include "dssi_data.h"

/* Define this for debug output.  */
#undef DEBUG_DSSI_PROVIDER

static void set_control (dssi_data *data, snd_seq_event_t *event);


/**
 * The jack callback routine.
 *
 * This function is called by the jack audio system in its own thread
 * whenever it needs new audio data.
 *
 */
static int
process (jack_nframes_t nframes, void *arg)
{    
  dssi_data *data = (dssi_data *) arg;
  int index;
  jack_default_audio_sample_t *buffer;

  /* Look through the event buffer to see if any control values
     need changing.  */
  for ( index = data->midiEventReadIndex; 
	index != data->midiEventWriteIndex;
	index = (index + 1) % EVENT_BUFFER_SIZE)
    {
      if (data->midiEventBuffer[index].type == SND_SEQ_EVENT_CONTROLLER)
	set_control (data, & data->midiEventBuffer[index]);
    }

  if (data->desc->run_synth)
    {
      /* Call the synth audio processing routine.  */
      data->desc->run_synth
	(data->plugin_handle,
	 nframes,
	 &data->midiEventBuffer[data->midiEventReadIndex],
	 data->midiEventWriteIndex - data->midiEventReadIndex);
    }
  else 
    if (data->desc->run_multiple_synths)
      {
	snd_seq_event_t *events = 
	  &data->midiEventBuffer[data->midiEventReadIndex];
	unsigned long event_count = 
	  data->midiEventWriteIndex - data->midiEventReadIndex;

	/* Call the synth audio processing routine.  */
	data->desc->run_multiple_synths
	  (1,
	   & (data->plugin_handle),
	   nframes,
	   &events,
	   &event_count);
      }

  /* Update the read index on our circular buffer.  */
  data->midiEventReadIndex = data->midiEventWriteIndex;

  /* Copy output from the synth to jack.  

     FIXME: This is hack that only gets one channel from the synth and
     send that to both jack ports (until we handle stero synths
     properly).

     FIXME: Can we avoid this copying?  */
  buffer = jack_port_get_buffer(data->jack_left_output_port, nframes);
  memcpy (buffer, data->left_buffer, nframes * sizeof(LADSPA_Data));
  buffer = jack_port_get_buffer(data->jack_right_output_port, nframes);
  memcpy (buffer, data->left_buffer, nframes * sizeof(LADSPA_Data));

  return 0;   
}


/**
 * Calculate a reasonable default value for a specific control port.
 * This is mostly copied from the DSSI example code.  Copyright info
 * is found at the top of this file.
 *
 */
static LADSPA_Data 
get_port_default (const LADSPA_Descriptor *plugin, 
		  int port, jack_nframes_t sample_rate)
{
  LADSPA_PortRangeHint hint = plugin->PortRangeHints[port];
  float lower = hint.LowerBound *
    (LADSPA_IS_HINT_SAMPLE_RATE(hint.HintDescriptor) ? sample_rate : 1.0f);
  float upper = hint.UpperBound *
    (LADSPA_IS_HINT_SAMPLE_RATE(hint.HintDescriptor) ? sample_rate : 1.0f);
  
  if (!LADSPA_IS_HINT_HAS_DEFAULT(hint.HintDescriptor)) 
    {
      if (!LADSPA_IS_HINT_BOUNDED_BELOW(hint.HintDescriptor) ||
	  !LADSPA_IS_HINT_BOUNDED_ABOVE(hint.HintDescriptor)) 
	{
	  /* No hint, its not bounded, wild guess */
	  return 0.0f;
	}
    
      if (lower <= 0.0f && upper >= 0.0f) 
	{
	  /* It spans 0.0, 0.0 is often a good guess */
	  return 0.0f;
	}
    
      /* No clues, return minimum */
      return lower;
    }
  
  /* Try all the easy ones */
  
  if (LADSPA_IS_HINT_DEFAULT_0(hint.HintDescriptor))
    return 0.0f;
  else if (LADSPA_IS_HINT_DEFAULT_1(hint.HintDescriptor)) 
    return 1.0f;
  else if (LADSPA_IS_HINT_DEFAULT_100(hint.HintDescriptor)) 
    return 100.0f;
  else if (LADSPA_IS_HINT_DEFAULT_440(hint.HintDescriptor)) 
    return 440.0f;
   
  /* All the others require some bounds */
  
  if (LADSPA_IS_HINT_BOUNDED_BELOW(hint.HintDescriptor)
      && (LADSPA_IS_HINT_DEFAULT_MINIMUM(hint.HintDescriptor)))
    return lower;

  if (LADSPA_IS_HINT_BOUNDED_ABOVE(hint.HintDescriptor))
    {
      if (LADSPA_IS_HINT_DEFAULT_MAXIMUM(hint.HintDescriptor))
	return upper;

      if (LADSPA_IS_HINT_BOUNDED_BELOW(hint.HintDescriptor)) 
	{
	  if (LADSPA_IS_HINT_DEFAULT_LOW(hint.HintDescriptor)) 
	    return lower * 0.75f + upper * 0.25f;
	  else if (LADSPA_IS_HINT_DEFAULT_MIDDLE(hint.HintDescriptor)) 
	    return lower * 0.5f + upper * 0.5f;
	  else if (LADSPA_IS_HINT_DEFAULT_HIGH(hint.HintDescriptor)) 
	    return lower * 0.25f + upper * 0.75f;
	}
    }
  
  /* fallback */
  return 0.0f;
}

/**
 * Set a control value by mapping the MIDI event to a suitable value
 * for this control.
 * This is mostly copied from the DSSI example code.  Copyright info
 * is found at the top of this file.
 *
 */
static void
set_control(dssi_data *data, snd_seq_event_t *event)
{
  unsigned control = event->data.control.param;
  unsigned port = data->control_port_map[control];

  const LADSPA_Descriptor *p = data->desc->LADSPA_Plugin;

  LADSPA_PortRangeHintDescriptor d = p->PortRangeHints[port].HintDescriptor;

  LADSPA_Data lb = p->PortRangeHints[port].LowerBound *
    (LADSPA_IS_HINT_SAMPLE_RATE(p->PortRangeHints[port].HintDescriptor) ?
     data->sample_rate : 1.0f);
  
  LADSPA_Data ub = p->PortRangeHints[port].UpperBound *
    (LADSPA_IS_HINT_SAMPLE_RATE(p->PortRangeHints[port].HintDescriptor) ?
     data->sample_rate : 1.0f);
  
  float value = (float)event->data.control.value;
  
  if (!LADSPA_IS_HINT_BOUNDED_BELOW(d)) 
    {
      if (!LADSPA_IS_HINT_BOUNDED_ABOVE(d)) 
	{
	  /* unbounded: might as well leave the value alone. */
	} 
      else 
	{
	  /* bounded above only. just shift the range. */
	  value = ub - 127.0f + value;
	}
    } 
  else 
    {
      if (!LADSPA_IS_HINT_BOUNDED_ABOVE(d)) 
	{
	  /* bounded below only. just shift the range. */
	  value = lb + value;
	} 
      else 
	{
	  /* bounded both ends.  more interesting. */
	  if (LADSPA_IS_HINT_LOGARITHMIC(d)) 
	    {
	      const float llb = logf(lb);
	      const float lub = logf(ub);
	      
	      value = expf(llb + ((lub - llb) * value / 127.0f));
	    } 
	  else 
	    {
	      value = lb + ((ub - lb) * value / 127.0f);
	    }
	}
    }
  
#ifdef DEBUG_DSSI_PROVIDER
  printf("MIDI controller %d=%d -> control in %u=%f\n", 
	 event->data.control.param,
	 event->data.control.value, 
	 data->control_value_map[control], value);
#endif
  
  data->control_values[data->control_value_map[control]] = value;
}

/**
 * Open a new synthesizer.  This currently involves instantiating a
 * new synth, creating a new jack client connection, and activating
 * both.
 *
 */
JNIEXPORT void JNICALL
Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_open_1 
  (JNIEnv *env, jclass clazz __attribute__((unused)), jlong handle)
{
  unsigned int port_count, j, cindex, ret;
  const char **ports;
  int controller = 0;
  dssi_data *data = (dssi_data *) (long) handle;
  jack_status_t status;
  char buffer[31];

  if ((data->jack_client = jack_client_open (data->desc->LADSPA_Plugin->Label,
					     JackUseExactName, &status)) == 0)
    {
      ret = snprintf(buffer, 31, "can't create jack client: %4d", status);
      assert (ret == 30);
      JCL_ThrowException (env, "javax/sound/midi/MidiUnavailableException",
			  buffer);
      return;
    } 

  /* Get the jack sample rate, which may be used in default control port
     value calculations.  */
  data->sample_rate = jack_get_sample_rate (data->jack_client);
  
  data->plugin_handle = 
    (data->desc->LADSPA_Plugin->instantiate)(data->desc->LADSPA_Plugin, 
					     data->sample_rate);
  
  if (jack_set_process_callback (data->jack_client, process, data) != 0)
    {
      JCL_ThrowException (env, "java/io/IOException", 
			  "can't set jack process callback");
      return;
    }
  
  data->jack_left_output_port =
    jack_port_register (data->jack_client, "output_left",
                        JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
  data->jack_right_output_port =
    jack_port_register (data->jack_client, "output_right",
                        JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);

  /* Count the number of controls and audio ouput ports.  */
  port_count = data->control_count = 0;
  for (j = 0; j < data->desc->LADSPA_Plugin->PortCount; j++) 
    {
      LADSPA_PortDescriptor pod =
    	data->desc->LADSPA_Plugin->PortDescriptors[j];
      
      if (LADSPA_IS_PORT_AUDIO(pod) && LADSPA_IS_PORT_OUTPUT(pod))
	port_count++;
      else if (LADSPA_IS_PORT_CONTROL(pod) && LADSPA_IS_PORT_INPUT(pod))
	data->control_count++;
    }

  /* Allocate the array of control values.  */
  data->control_values = 
    (LADSPA_Data *) JCL_malloc (env, 
				data->control_count * sizeof (LADSPA_Data));

  /* Initialize the MIDI control map.  */
  memset (data->control_value_map, 0, data->control_count * sizeof(unsigned));
  
  /* Create buffers for each port.  */
  for (cindex = 0, j = 0; j < data->desc->LADSPA_Plugin->PortCount; j++) 
    {  
      LADSPA_PortDescriptor pod =
	data->desc->LADSPA_Plugin->PortDescriptors[j];
      if (LADSPA_IS_PORT_AUDIO(pod) && LADSPA_IS_PORT_OUTPUT(pod))
  	{
	  data->left_buffer = 
	    (float *) calloc(jack_get_buffer_size(data->jack_client), 
			     sizeof(float));
	  (data->desc->LADSPA_Plugin->connect_port)(data->plugin_handle, j, 
						    data->left_buffer);
  	}
      else 
	if (LADSPA_IS_PORT_CONTROL(pod) && LADSPA_IS_PORT_INPUT(pod))
	  {
	    /* This is an input control port.  Connect it to a properly
	       initialized value in our controller value array.  */
	    (data->desc->LADSPA_Plugin->connect_port)
	      (data->plugin_handle, j, &(data->control_values[cindex]));
	    data->control_values[cindex] = 
	      get_port_default (data->desc->LADSPA_Plugin,
				j, data->sample_rate);

	    /* Set up the mapping between MIDI controllers and this
	       contoller value.  */
	    if (data->desc->get_midi_controller_for_port)
	      {
		controller = data->desc->
		  get_midi_controller_for_port(data->plugin_handle, j);

		if ((controller != DSSI_NONE) && DSSI_IS_CC(controller))
		  {
		    data->control_value_map[DSSI_CC_NUMBER(controller)] = cindex;
		    data->control_port_map[DSSI_CC_NUMBER(controller)] = j;

#ifdef DEBUG_DSSI_PROVIDER
		    printf ("MIDI Controller 0x%x [%s] = %g\n", 
			    DSSI_CC_NUMBER(controller),
			    data->desc->LADSPA_Plugin->PortNames[j],
			    data->control_values[cindex]);
#endif
		  }
	      }

	    cindex++;
	  }
    }
  
  (data->desc->LADSPA_Plugin->activate)(data->plugin_handle);

  if (jack_activate (data->jack_client))
    JCL_ThrowException (env, "java/io/IOException", 
			"can't activate jack client"); 

  /* Try to connect the synth output to hardware audio ports.  */
  ports = jack_get_ports (data->jack_client, NULL, NULL, 
			  JackPortIsPhysical | JackPortIsInput);
  if (ports)
    {
      if (ports[0] && ports[1]) 
	{
	  /* Don't bother checking return values.  Failing is OK.  */
	  jack_connect (data->jack_client, 
			jack_port_name (data->jack_left_output_port),
			ports[0]);
	  jack_connect (data->jack_client, 
			jack_port_name (data->jack_right_output_port),
			ports[1]);
	}
      free(ports);
    }
}

/**
 * This is called when we receive a new MIDI CONTROL CHANGE message.
 * Simply stick an appropriate event in the event buffer.  This will
 * get processed in the jack callback function.
 */
JNIEXPORT void JNICALL 
Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_controlChange_1 
  (JNIEnv *env __attribute__((unused)), jclass clazz __attribute__((unused)), 
   jlong handle, jint channel, jint control, jint value)
{
  dssi_data *data = JLONG_TO_PTR(dssi_data,handle);

  /* Insert this event in the event buffer.  */
  snd_seq_event_t *ev = & data->midiEventBuffer[data->midiEventWriteIndex];

  /* Set the event value.  */
  snd_seq_ev_set_controller (ev, channel, control, value);

  data->midiEventWriteIndex = 
    (data->midiEventWriteIndex + 1) % EVENT_BUFFER_SIZE;
}

/**
 * This is called when we receive a new MIDI NOTE ON message.  Simply
 * stick an appropriate event in the event buffer.  This will get
 * processed in the jack callback function.
 */
JNIEXPORT void JNICALL 
Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_noteOn_1 
  (JNIEnv *env __attribute__((unused)), jclass clazz __attribute__((unused)), 
   jlong handle, jint channel, jint note, jint velocity)
{
  dssi_data *data = JLONG_TO_PTR(dssi_data,handle);

  /* Insert this event in the event buffer.  */
  snd_seq_event_t *ev = & data->midiEventBuffer[data->midiEventWriteIndex];

  ev->type = SND_SEQ_EVENT_NOTEON;
  ev->data.control.channel = channel;
  ev->data.note.note = note;
  ev->data.note.velocity = velocity;

  data->midiEventWriteIndex = 
    (data->midiEventWriteIndex + 1) % EVENT_BUFFER_SIZE;
}

/**
 * This is called when we receive a new MIDI NOTE OFF message.  Simply
 * stick an appropriate event in the event buffer.  This will get
 * processed in the jack callback function.
 */
JNIEXPORT void JNICALL 
Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_noteOff_1 
  (JNIEnv *env __attribute__((unused)), 
   jclass clazz __attribute__((unused)), 
   jlong handle, jint channel, jint note, jint velocity)
{
  dssi_data *data = JLONG_TO_PTR(dssi_data,handle);

  /* Insert this event in the event buffer.  */
  snd_seq_event_t *ev = & data->midiEventBuffer[data->midiEventWriteIndex];

  ev->type = SND_SEQ_EVENT_NOTEOFF;
  ev->data.control.channel = channel;
  ev->data.note.note = note;
  ev->data.note.velocity = velocity;

  data->midiEventWriteIndex = 
    (data->midiEventWriteIndex + 1) % EVENT_BUFFER_SIZE;
}

JNIEXPORT void JNICALL 
Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_setPolyPressure_1 
  (JNIEnv *env __attribute__((unused)), jclass clazz __attribute__((unused)), 
   jlong handle __attribute__((unused)), jint channel __attribute__((unused)), 
   jint note __attribute__((unused)), jint velocity __attribute__((unused)))
{
}

JNIEXPORT jint JNICALL 
Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_getPolyPressure_1 
  (JNIEnv *env __attribute__((unused)), jclass clazz __attribute__((unused)), 
   jlong handle __attribute__((unused)), jint channel __attribute__((unused)), 
   jint note __attribute__((unused)))
{
  return 0;
}

JNIEXPORT void JNICALL 
Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_close_1 
  (JNIEnv *env __attribute__((unused)), jclass clazz __attribute__((unused)), 
   jlong handle __attribute__((unused)))
{
}

/* FIXME: These next three functions are really inefficient because
   we're instantiating and cleaning up plugin instances just to query
   values.  */

JNIEXPORT jstring JNICALL 
Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_getProgramName_1 
  (JNIEnv *env, jclass clazz __attribute__((unused)), 
   jlong handle, jint index)
{
  LADSPA_Handle lhandle;
  jstring name = (jstring) NULL;
  dssi_data *data = JLONG_TO_PTR(dssi_data, handle);
  if (data->desc->get_program == NULL)
    return NULL;
  lhandle =
    (data->desc->LADSPA_Plugin->instantiate)(data->desc->LADSPA_Plugin, 
					     48000);
  const DSSI_Program_Descriptor *program = 
    (data->desc->get_program)(lhandle, (unsigned long) index);
  if (program)
    name = (*env)->NewStringUTF (env, program->Name);
  (data->desc->LADSPA_Plugin->cleanup)(lhandle);

  return name;
}

JNIEXPORT jint JNICALL
Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_getProgramBank_1 
  (JNIEnv *env __attribute__((unused)), jclass clazz __attribute__((unused)),
   jlong handle, jint index)
{
  LADSPA_Handle lhandle;
  jint result = -1;
  dssi_data *data = JLONG_TO_PTR(dssi_data, handle);
  lhandle =
    (data->desc->LADSPA_Plugin->instantiate)(data->desc->LADSPA_Plugin, 
					     48000);
  const DSSI_Program_Descriptor *program = 
    (data->desc->get_program)(lhandle, (unsigned long) index);
  if (program)
    result = (jint) program->Bank;
  (data->desc->LADSPA_Plugin->cleanup)(lhandle);
  return result;
}

JNIEXPORT jint JNICALL 
Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_getProgramProgram_1 
  (JNIEnv *env __attribute__((unused)), jclass clazz __attribute__((unused)), 
   jlong handle, jint index)
{
  LADSPA_Handle lhandle;
  jint result = -1;
  dssi_data *data = JLONG_TO_PTR(dssi_data, handle);
  lhandle =
    (data->desc->LADSPA_Plugin->instantiate)(data->desc->LADSPA_Plugin, 
					     48000);
  const DSSI_Program_Descriptor *program = 
    (data->desc->get_program)(lhandle, (unsigned long) index);
  if (program)
    result = (jint) program->Program;
  (data->desc->LADSPA_Plugin->cleanup)(lhandle);
  return result;
}


JNIEXPORT void JNICALL 
Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_selectProgram_1 
  (JNIEnv *env __attribute__((unused)), jclass clazz __attribute__((unused)), 
   jlong handle, jint bank, jint program)
{
  dssi_data *data = JLONG_TO_PTR(dssi_data, handle);

  (data->desc->select_program)(data->plugin_handle, 
			       (unsigned) bank, (unsigned) program);
}