• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*----------------------------------------------------------------------------
2  *
3  * File:
4  * eas_vm_protos.h
5  *
6  * Contents and purpose:
7  * Declarations, interfaces, and prototypes for voice manager.
8  *
9  * Copyright Sonic Network Inc. 2004
10 
11  * Licensed under the Apache License, Version 2.0 (the "License");
12  * you may not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  *
15  *      http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  *
23  *----------------------------------------------------------------------------
24  * Revision Control:
25  *   $Revision: 736 $
26  *   $Date: 2007-06-22 13:51:24 -0700 (Fri, 22 Jun 2007) $
27  *----------------------------------------------------------------------------
28 */
29 
30 #ifndef _EAS_VM_PROTOS_H
31 #define _EAS_VM_PROTOS_H
32 
33 // includes
34 #include "eas_data.h"
35 #include "eas_sndlib.h"
36 
37 /*----------------------------------------------------------------------------
38  * VMInitialize()
39  *----------------------------------------------------------------------------
40  * Purpose:
41  *
42  * Inputs:
43  * psEASData - pointer to overall EAS data structure
44  *
45  * Outputs:
46  *
47  *----------------------------------------------------------------------------
48 */
49 EAS_RESULT VMInitialize (S_EAS_DATA *pEASData);
50 
51 /*----------------------------------------------------------------------------
52  * VMInitMIDI()
53  *----------------------------------------------------------------------------
54  * Purpose:
55  *
56  * Inputs:
57  * psEASData - pointer to overall EAS data structure
58  *
59  * Outputs:
60  *
61  *----------------------------------------------------------------------------
62 */
63 EAS_RESULT VMInitMIDI (S_EAS_DATA *pEASData, S_SYNTH **ppSynth);
64 
65 /*----------------------------------------------------------------------------
66  * VMInitializeAllChannels()
67  *----------------------------------------------------------------------------
68  * Purpose:
69  *
70  * Inputs:
71  * psEASData - pointer to overall EAS data structure
72  *
73  * Outputs:
74  *
75  *----------------------------------------------------------------------------
76 */
77 void VMInitializeAllChannels (S_VOICE_MGR *pVoiceMgr, S_SYNTH *pSynth);
78 
79 /*----------------------------------------------------------------------------
80  * VMResetControllers()
81  *----------------------------------------------------------------------------
82  * Purpose:
83  *
84  * Inputs:
85  * psEASData - pointer to overall EAS data structure
86  *
87  * Outputs:
88  *
89  *----------------------------------------------------------------------------
90 */
91 void VMResetControllers (S_SYNTH *pSynth);
92 
93 /*----------------------------------------------------------------------------
94  * VMInitMIPTable()
95  *----------------------------------------------------------------------------
96  * Purpose:
97  * Initialize the SP-MIDI MIP table
98  *
99  * Inputs:
100  * pEASData         - pointer to synthesizer instance data
101  * mute             - EAS_FALSE to unmute channels, EAS_TRUE to mute
102  *
103  * Outputs:
104  *
105  *
106  * Side Effects:
107  *
108  *----------------------------------------------------------------------------
109 */
110 void VMInitMIPTable (S_SYNTH *pSynth);
111 
112 /*----------------------------------------------------------------------------
113  * VMSetMIPEntry()
114  *----------------------------------------------------------------------------
115  * Purpose:
116  * Sets the priority and MIP level for a MIDI channel
117  *
118  * Inputs:
119  * pEASData         - pointer to synthesizer instance data
120  * channel          - MIDI channel number
121  * priority         - priority (0-15 with 0 = highest priority)
122  * mip              - maximum instantaneous polyphony
123  *
124  * Outputs:
125  *
126  *
127  * Side Effects:
128  *
129  *----------------------------------------------------------------------------
130 */
131 void VMSetMIPEntry (S_VOICE_MGR *pVoiceMgr, S_SYNTH *pSynth, EAS_U8 channel, EAS_U8 priority, EAS_U8 mip);
132 
133 /*----------------------------------------------------------------------------
134  * VMUpdateMIPTable()
135  *----------------------------------------------------------------------------
136  * Purpose:
137  * This routine is called when the polyphony count in the synthesizer changes
138  *
139  * Inputs:
140  * pEASData         - pointer to synthesizer instance data
141  *
142  * Outputs:
143  *
144  *
145  * Side Effects:
146  *
147  *----------------------------------------------------------------------------
148 */
149 void VMUpdateMIPTable (S_VOICE_MGR *pVoiceMgr, S_SYNTH *pSynth);
150 
151 /*----------------------------------------------------------------------------
152  * VMInitializeAllVoices()
153  *----------------------------------------------------------------------------
154  * Purpose:
155  *
156  * Inputs:
157  * psEASData - pointer to overall EAS data structure
158  *
159  * Outputs:
160  *
161  *----------------------------------------------------------------------------
162 */
163 void VMInitializeAllVoices (S_VOICE_MGR *pVoiceMgr, EAS_INT vSynthNum);
164 
165 /*----------------------------------------------------------------------------
166  * VMStartNote()
167  *----------------------------------------------------------------------------
168  * Purpose:
169  * Update the synth's state to play the requested note on the requested
170  * channel if possible.
171  *
172  * Inputs:
173  * nChannel - the MIDI channel
174  * nKeyNumber - the MIDI key number for this note
175  * nNoteVelocity - the key velocity for this note
176  * psEASData - pointer to overall EAS data structure
177  *
178  * Outputs:
179  *
180  *----------------------------------------------------------------------------
181 */
182 void VMStartNote (S_VOICE_MGR *pVoiceMgr, S_SYNTH *pSynth, EAS_U8 channel, EAS_U8 note, EAS_U8 velocity);
183 
184 /*----------------------------------------------------------------------------
185  * VMCheckKeyGroup()
186  *----------------------------------------------------------------------------
187  * Purpose:
188  * If the note that we've been asked to start is in the same key group as
189  * any currently playing notes, then we must shut down the currently playing
190  * note in the same key group and then start the newly requested note.
191  *
192  * Inputs:
193  * nChannel - synth channel that wants to start a new note
194  * nKeyNumber - new note's midi note number
195  * nRegionIndex - calling routine finds this index and gives to us
196  * nNoteVelocity - new note's velocity
197  * psEASData - pointer to overall EAS data structure
198  *
199  * Outputs:
200  * pbVoiceStealingRequired - flag: this routine sets true if we needed to
201  *                                 steal a voice
202  *
203  * Side Effects:
204  * gsSynthObject.m_sVoice[free voice num].m_nKeyNumber may be assigned
205  * gsSynthObject.m_sVoice[free voice num].m_nVelocity may be assigned
206  *----------------------------------------------------------------------------
207 */
208 void VMCheckKeyGroup (S_VOICE_MGR *pVoiceMgr, S_SYNTH *pSynth, EAS_U16 keyGroup, EAS_U8 channel);
209 
210 /*----------------------------------------------------------------------------
211  * VMCheckPolyphonyLimiting()
212  *----------------------------------------------------------------------------
213  * Purpose:
214  * We only play at most 2 of the same note on a MIDI channel.
215  * E.g., if we are asked to start note 36, and there are already two voices
216  * that are playing note 36, then we must steal the voice playing
217  * the oldest note 36 and use that stolen voice to play the new note 36.
218  *
219  * Inputs:
220  * nChannel - synth channel that wants to start a new note
221  * nKeyNumber - new note's midi note number
222  * nNoteVelocity - new note's velocity
223  * psEASData - pointer to overall EAS data structure
224  *
225  * Outputs:
226  * pbVoiceStealingRequired - flag: this routine sets true if we needed to
227  *                                 steal a voice
228  * *
229  * Side Effects:
230  * psSynthObject->m_sVoice[free voice num].m_nKeyNumber may be assigned
231  * psSynthObject->m_sVoice[free voice num].m_nVelocity may be assigned
232  *----------------------------------------------------------------------------
233 */
234 EAS_BOOL VMCheckPolyphonyLimiting (S_VOICE_MGR *pVoiceMgr, S_SYNTH *pSynth, EAS_U8 channel, EAS_U8 note, EAS_U8 velocity, EAS_U16 regionIndex, EAS_I32 lowVoice, EAS_I32 highVoice);
235 
236 /*----------------------------------------------------------------------------
237  * VMStopNote()
238  *----------------------------------------------------------------------------
239  * Purpose:
240  * Update the synth's state to end the requested note on the requested
241  * channel.
242  *
243  * Inputs:
244  * nChannel - the MIDI channel
245  * nKeyNumber - the key number of the note to stop
246  * nNoteVelocity - the note-off velocity
247  * psEASData - pointer to overall EAS data structure
248  *
249  * Outputs:
250  * Side Effects:
251  * gsSynthObject.m_sVoice[free voice num].m_nSynthChannel may be assigned
252  * gsSynthObject.m_sVoice[free voice num].m_nKeyNumber is assigned
253  * gsSynthObject.m_sVoice[free voice num].m_nVelocity is assigned
254  *----------------------------------------------------------------------------
255 */
256 void VMStopNote (S_VOICE_MGR *pVoiceMgr, S_SYNTH *pSynth, EAS_U8 channel, EAS_U8 key, EAS_U8 velocity);
257 
258 /*----------------------------------------------------------------------------
259  * VMFindAvailableVoice()
260  *----------------------------------------------------------------------------
261  * Purpose:
262  * Find an available voice and return the voice number if available.
263  *
264  * Inputs:
265  * pnVoiceNumber - really an output, see below
266  * psEASData - pointer to overall EAS data structure
267  *
268  * Outputs:
269  * pnVoiceNumber - returns the voice number of available voice if found
270  * success - if there is an available voice
271  * failure - otherwise
272  *----------------------------------------------------------------------------
273 */
274 EAS_RESULT VMFindAvailableVoice (S_VOICE_MGR *pVoiceMgr, EAS_INT *pVoiceNumber, EAS_I32 lowVoice, EAS_I32 highVoice);
275 
276 /*----------------------------------------------------------------------------
277  * VMStealVoice()
278  *----------------------------------------------------------------------------
279  * Purpose:
280  * Steal a voice and return the voice number
281  *
282  * Stealing algorithm: steal the best choice with minimal work, taking into
283  * account SP-Midi channel priorities and polyphony allocation.
284  *
285  * In one pass through all the voices, figure out which voice to steal
286  * taking into account a number of different factors:
287  * Priority of the voice's MIDI channel
288  * Number of voices over the polyphony allocation for voice's MIDI channel
289  * Amplitude of the voice
290  * Note age
291  * Key velocity (for voices that haven't been started yet)
292  * If any matching notes are found
293  *
294  * Inputs:
295  * nChannel - the channel that this voice wants to be started on
296  * nKeyNumber - the key number for this new voice
297  * psEASData - pointer to overall EAS data structure
298  *
299  * Outputs:
300  * pnVoiceNumber - voice stolen
301  * EAS_RESULT EAS_SUCCESS - always successful
302  *----------------------------------------------------------------------------
303 */
304 EAS_RESULT VMStealVoice (S_VOICE_MGR *pVoiceMgr, S_SYNTH *pSynth, EAS_INT *pVoiceNumber, EAS_U8 channel, EAS_U8 note, EAS_I32 lowVoice, EAS_I32 highVoice);
305 
306 /*----------------------------------------------------------------------------
307  * VMAddSamples()
308  *----------------------------------------------------------------------------
309  * Purpose:
310  * Synthesize the requested number of samples.
311  *
312  * Inputs:
313  * nNumSamplesToAdd - number of samples to write to buffer
314  * psEASData - pointer to overall EAS data structure
315  *
316  * Outputs:
317  * number of samples actually written to buffer
318  *
319  * Side Effects:
320  * - samples are added to the presently free buffer
321  *
322  *----------------------------------------------------------------------------
323 */
324 EAS_I32 VMAddSamples (S_VOICE_MGR *pVoiceMgr, EAS_I32 *pMixBuffer, EAS_I32 numSamplesToAdd);
325 
326 /*----------------------------------------------------------------------------
327  * VMProgramChange()
328  *----------------------------------------------------------------------------
329  * Purpose:
330  * Change the instrument (program) for the given channel.
331  *
332  * Depending on the program number, and the bank selected for this channel, the
333  * program may be in ROM, RAM (from SMAF or CMX related RAM wavetable), or
334  * Alternate wavetable (from mobile DLS or other DLS file)
335  *
336  * This function figures out what wavetable should be used, and sets it up as the
337  * wavetable to use for this channel. Also the channel may switch from a melodic
338  * channel to a rhythm channel, or vice versa.
339  *
340  * Inputs:
341  *
342  * Outputs:
343  * Side Effects:
344  * gsSynthObject.m_sChannel[nChannel].m_nProgramNumber is likely changed
345  * gsSynthObject.m_sChannel[nChannel].m_psEAS may be changed
346  * gsSynthObject.m_sChannel[nChannel].m_bRhythmChannel may be changed
347  *
348  *----------------------------------------------------------------------------
349 */
350 void VMProgramChange (S_VOICE_MGR *pVoiceMgr, S_SYNTH *pSynth, EAS_U8 channel, EAS_U8 program);
351 
352 /*----------------------------------------------------------------------------
353  * VMChannelPressure()
354  *----------------------------------------------------------------------------
355  * Purpose:
356  * Change the channel pressure for the given channel
357  *
358  * Inputs:
359  * nChannel - the MIDI channel
360  * nVelocity - the channel pressure value
361  * psEASData - pointer to overall EAS data structure
362  *
363  * Outputs:
364  * Side Effects:
365  * gsSynthObject.m_sChannel[nChannel].m_nChannelPressure is updated
366  *----------------------------------------------------------------------------
367 */
368 void VMChannelPressure (S_SYNTH *pSynth, EAS_U8 channel, EAS_U8 value);
369 
370 /*----------------------------------------------------------------------------
371  * VMPitchBend()
372  *----------------------------------------------------------------------------
373  * Purpose:
374  * Change the pitch wheel value for the given channel.
375  * This routine constructs the proper 14-bit argument when the calling routine
376  * passes the pitch LSB and MSB.
377  *
378  * Note: some midi disassemblers display a bipolar pitch bend value.
379  * We can display the bipolar value using
380  * if m_nPitchBend >= 0x2000
381  *      bipolar pitch bend = postive (m_nPitchBend - 0x2000)
382  * else
383  *      bipolar pitch bend = negative (0x2000 - m_nPitchBend)
384  *
385  * Inputs:
386  * nChannel - the MIDI channel
387  * nPitchLSB - the LSB byte from the pitch bend message
388  * nPitchMSB - the MSB byte from the message
389  * psEASData - pointer to overall EAS data structure
390  *
391  * Outputs:
392  *
393  * Side Effects:
394  * gsSynthObject.m_sChannel[nChannel].m_nPitchBend is changed
395  *
396  *----------------------------------------------------------------------------
397 */
398 void VMPitchBend (S_SYNTH *pSynth, EAS_U8 channel, EAS_U8 pitchLSB, EAS_U8 pitchMSB);
399 
400 /*----------------------------------------------------------------------------
401  * VMControlChange()
402  *----------------------------------------------------------------------------
403  * Purpose:
404  * Change the controller (or mode) for the given channel.
405  *
406  * Inputs:
407  * nChannel - the MIDI channel
408  * nControllerNumber - the controller number
409  * nControlValue - the controller number for this control change
410  * nControlValue - the value for this control change
411  * psEASData - pointer to overall EAS data structure
412  *
413  * Outputs:
414  * Side Effects:
415  * gsSynthObject.m_sChannel[nChannel] controller is changed
416  *
417  *----------------------------------------------------------------------------
418 */
419 void VMControlChange (S_VOICE_MGR *pVoiceMgr, S_SYNTH *pSynth, EAS_U8 channel, EAS_U8 controller, EAS_U8 value);
420 
421 /*----------------------------------------------------------------------------
422  * VMUpdateRPNStateMachine()
423  *----------------------------------------------------------------------------
424  * Purpose:
425  * Call this function when we want to parse a stream of RPN messages.
426  * NOTE: The synth has only one set of global RPN data instead of RPN data
427  * per channel.
428  * So actually, we don't really need to look at the nChannel parameter,
429  * but we pass it to facilitate future upgrades. Furthermore, we only
430  * support RPN0 (pitch bend sensitivity), RPN1 (fine tuning) and
431  * RPN2 (coarse tuning). Any other RPNs are rejected.
432  *
433  * Inputs:
434  * nChannel - the MIDI channel
435  * nControllerNumber - the RPN controller number
436  * nControlValue - the value for this control change
437  * psEASData - pointer to overall EAS data structure
438  *
439  * Outputs:
440  *
441  * Side Effects:
442  * gsSynthObject.m_RPN0 (or m_RPN1 or m_RPN2) may be updated if the
443  * proper RPN message sequence is parsed.
444  *----------------------------------------------------------------------------
445 */
446 EAS_RESULT VMUpdateRPNStateMachine (S_SYNTH *pSynth, EAS_U8 channel, EAS_U8 controller, EAS_U8 value);
447 
448 /*----------------------------------------------------------------------------
449  * VMUpdateStaticChannelParameters()
450  *----------------------------------------------------------------------------
451  * Purpose:
452  * Update all of the static channel parameters for channels that have had
453  * a controller change values
454  * Or if the synth has signalled that all channels must forcibly
455  * be updated
456  *
457  * Inputs:
458  * psEASData - pointer to overall EAS data structure
459  *
460  * Outputs:
461  * none
462  *
463  * Side Effects:
464  * - psSynthObject->m_sChannel[].m_nStaticGain and m_nStaticPitch
465  * are updated for channels whose controller values have changed
466  * or if the synth has signalled that all channels must forcibly
467  * be updated
468  *----------------------------------------------------------------------------
469 */
470 void VMUpdateStaticChannelParameters (S_VOICE_MGR *pVoiceMgr, S_SYNTH *pSynth);
471 
472 /*----------------------------------------------------------------------------
473  * VMReleaseAllDeferredNoteOffs()
474  *----------------------------------------------------------------------------
475  * Purpose:
476  * Call this functin when the sustain flag is presently set but
477  * we are now transitioning from damper pedal on to
478  * damper pedal off. This means all notes in this channel
479  * that received a note off while the damper pedal was on, and
480  * had their note-off requests deferred, should now proceed to
481  * the release state.
482  *
483  * Inputs:
484  * nChannel - this channel has its sustain pedal transitioning from on to off
485  * psEASData - pointer to overall EAS data structure
486  *
487  * Outputs:
488  * Side Effects:
489  * any voice with deferred note offs on this channel are updated such that
490  *
491  *
492  *----------------------------------------------------------------------------
493 */
494 void VMReleaseAllDeferredNoteOffs (S_VOICE_MGR *pVoiceMgr, S_SYNTH *pSynth, EAS_U8 channel);
495 
496 /*----------------------------------------------------------------------------
497  * VMCatchNotesForSustainPedal()
498  *----------------------------------------------------------------------------
499  * Purpose:
500  * Call this function when the sustain flag is presently clear and
501  * the damper pedal is off and we are transitioning from damper pedal OFF to
502  * damper pedal ON. Currently sounding notes should be left
503  * unchanged. However, we should try to "catch" notes if possible.
504  * If any notes have levels >= sustain level, catch them,
505  * otherwise, let them continue to release.
506  *
507  * Inputs:
508  * nChannel - this channel has its sustain pedal transitioning from on to off
509  * psEASData - pointer to overall EAS data structure
510  *
511  * Outputs:
512  * Side Effects:
513  * any voice with deferred note offs on this channel are updated such that
514  * psVoice->m_sEG1.m_eState = eEnvelopeStateSustainPedal
515  *----------------------------------------------------------------------------
516 */
517 void VMCatchNotesForSustainPedal (S_VOICE_MGR *pVoiceMgr, S_SYNTH *pSynth, EAS_U8 channel);
518 
519 /*----------------------------------------------------------------------------
520  * VMUpdateAllNotesAge()
521  *----------------------------------------------------------------------------
522  * Purpose:
523  * Increment the note age for all voices older than the age of the voice
524  * that is stopping, effectively making the voices "younger".
525  *
526  * Inputs:
527  * nAge - age of voice that is going away
528  * psEASData - pointer to overall EAS data structure
529  *
530  * Outputs:
531  *
532  * Side Effects:
533  * m_nAge for some voices is incremented
534  *----------------------------------------------------------------------------
535 */
536 void VMUpdateAllNotesAge (S_VOICE_MGR *pVoiceMgr, EAS_U16 nAge);
537 
538 /*----------------------------------------------------------------------------
539  * VMFindRegionIndex()
540  *----------------------------------------------------------------------------
541  * Purpose:
542  * Find the region index for the given instrument using the midi key number
543  * and the RPN2 (coarse tuning) value. By using RPN2 as part of the
544  * region selection process, we reduce the amount a given sample has
545  * to be transposed by selecting the closest recorded root instead.
546  *
547  * Inputs:
548  * nChannel - current channel for this note
549  * nKeyNumber - current midi note number
550  * psEASData - pointer to overall EAS data structure
551  *
552  * Outputs:
553  * pnRegionIndex - valid only if we returned success
554  * success if we found the region index number, otherwise
555  * failure
556  *
557  * Side Effects:
558  *----------------------------------------------------------------------------
559 */
560 EAS_RESULT VMFindRegionIndex (S_VOICE_MGR *pVoiceMgr, EAS_U8 channel, EAS_U8 note, EAS_U16 *pRegionIndex);
561 
562 /*----------------------------------------------------------------------------
563  * VMIncRefCount()
564  *----------------------------------------------------------------------------
565  * Increment reference count for virtual synth
566  *----------------------------------------------------------------------------
567 */
568 void VMIncRefCount (S_SYNTH *pSynth);
569 
570 /*----------------------------------------------------------------------------
571  * VMReset()
572  *----------------------------------------------------------------------------
573  * Purpose:
574  * We call this routine to start the process of reseting the synth.
575  * This routine sets a flag for the entire synth indicating that we want
576  * to reset.
577  * We also force all voices to mute quickly.
578  * However, we do not actually perform any synthesis in this routine. That
579  * is, we do not ramp the voices down from this routine, but instead, we
580  * let the "regular" synth processing steps take care of adding the ramp
581  * down samples to the output buffer. After we are sure that all voices
582  * have completed ramping down, we continue the process of resetting the
583  * synth (from another routine).
584  *
585  * Inputs:
586  * psEASData - pointer to overall EAS data structure
587  *
588  * Outputs:
589  *
590  * Side Effects:
591  * - set a flag (in gsSynthObject.m_nFlags) indicating synth reset requested.
592  * - force all voices to update their envelope states to mute
593  *
594  *----------------------------------------------------------------------------
595 */
596 void VMReset (S_VOICE_MGR *pVoiceMgr, S_SYNTH *pSynth, EAS_BOOL force);
597 
598 /*----------------------------------------------------------------------------
599  * VMMuteAllVoices()
600  *----------------------------------------------------------------------------
601  * Purpose:
602  * We call this in an emergency reset situation.
603  * This forces all voices to mute quickly.
604  *
605  * Inputs:
606  * psEASData - pointer to overall EAS data structure
607  *
608  * Outputs:
609  *
610  * Side Effects:
611  * - forces all voices to update their envelope states to mute
612  *
613  *----------------------------------------------------------------------------
614 */
615 void VMMuteVoice (S_VOICE_MGR *pVoiceMgr, EAS_I32 voiceNum);
616 void VMMuteAllVoices (S_VOICE_MGR *pVoiceMgr, S_SYNTH *pSynth);
617 
618 /*----------------------------------------------------------------------------
619  * VMReleaseAllVoices()
620  *----------------------------------------------------------------------------
621  * Purpose:
622  * We call this after we've encountered the end of the Midi file.
623  * This ensures all voice are either in release (because we received their
624  * note off already) or forces them to mute quickly.
625  * We use this as a safety to prevent bad midi files from playing forever.
626  *
627  * Inputs:
628  * psEASData - pointer to overall EAS data structure
629  *
630  * Outputs:
631  *
632  * Side Effects:
633  * - forces all voices to update their envelope states to release or mute
634  *
635  *----------------------------------------------------------------------------
636 */
637 void VMReleaseAllVoices (S_VOICE_MGR *pVoiceMgr, S_SYNTH *pSynth);
638 
639 /*----------------------------------------------------------------------------
640  * VMAllNotesOff()
641  *----------------------------------------------------------------------------
642  * Purpose:
643  * Quickly mute all notes on the given channel.
644  *
645  * Inputs:
646  * nChannel - quickly turn off all notes on this channel
647  * psEASData - pointer to overall EAS data structure
648  *
649  * Outputs:
650  *
651  * Side Effects:
652  * - forces all voices on this channel to update their envelope states to mute
653  *
654  *----------------------------------------------------------------------------
655 */
656 void VMAllNotesOff (S_VOICE_MGR *pVoiceMgr, S_SYNTH *pSynth, EAS_U8 channel);
657 
658 /*----------------------------------------------------------------------------
659  * VMDeferredStopNote()
660  *----------------------------------------------------------------------------
661  * Purpose:
662  * Stop the notes that had deferred note-off requests.
663  *
664  * Inputs:
665  * psEASData - pointer to overall EAS data structure
666  *
667  * Outputs:
668  * None.
669  *
670  * Side Effects:
671  * voices that have had deferred note-off requests are now put into release
672  * gsSynthObject.m_sVoice[i].m_nFlags has the VOICE_FLAG_DEFER_MIDI_NOTE_OFF
673  *  cleared
674  *----------------------------------------------------------------------------
675 */
676 void VMDeferredStopNote (S_VOICE_MGR *pVoiceMgr, S_SYNTH *pSynth);
677 
678 /*----------------------------------------------------------------------------
679  * VMSetSynthPolyphony()
680  *----------------------------------------------------------------------------
681  * Purpose:
682  * Set the synth to a new polyphony value. Value must be >= 1 and
683  * <= MAX_SYNTH_VOICES. This function will pin the polyphony at those limits
684  *
685  * Inputs:
686  * pVoiceMgr        pointer to synthesizer data
687  * synth            synthesizer number (0 = onboard, 1 = DSP)
688  * polyphonyCount   desired polyphony count
689  *
690  * Outputs:
691  *
692  * Side Effects:
693  *
694  *----------------------------------------------------------------------------
695 */
696 EAS_RESULT VMSetSynthPolyphony (S_VOICE_MGR *pVoiceMgr, EAS_I32 synth, EAS_I32 polyphonyCount);
697 
698 /*----------------------------------------------------------------------------
699  * VMGetSynthPolyphony()
700  *----------------------------------------------------------------------------
701  * Purpose:
702  * Set the synth to a new polyphony value. Value must be >= 1 and
703  * <= MAX_SYNTH_VOICES. This function will pin the polyphony at those limits
704  *
705  * Inputs:
706  * pVoiceMgr        pointer to synthesizer data
707  * synth            synthesizer number (0 = onboard, 1 = DSP)
708  * polyphonyCount   desired polyphony count
709  *
710  * Outputs:
711  *
712  * Side Effects:
713  *
714  *----------------------------------------------------------------------------
715 */
716 EAS_RESULT VMGetSynthPolyphony (S_VOICE_MGR *pVoiceMgr, EAS_I32 synth, EAS_I32 *pPolyphonyCount);
717 
718 /*----------------------------------------------------------------------------
719  * VMSetPolyphony()
720  *----------------------------------------------------------------------------
721  * Purpose:
722  * Set the virtual synth polyphony. 0 = no limit (i.e. can use
723  * all available voices).
724  *
725  * Inputs:
726  * pVoiceMgr        pointer to synthesizer data
727  * polyphonyCount   desired polyphony count
728  * pSynth           pointer to virtual synth
729  *
730  * Outputs:
731  * Returns error code
732  *
733  * Side Effects:
734  *
735  *----------------------------------------------------------------------------
736 */
737 EAS_RESULT VMSetPolyphony (S_VOICE_MGR *pVoiceMgr, S_SYNTH *pSynth, EAS_I32 polyphonyCount);
738 
739 /*----------------------------------------------------------------------------
740  * VMGetPolyphony()
741  *----------------------------------------------------------------------------
742  * Purpose:
743  * Returns the current polyphony setting
744  *
745  * Inputs:
746  * pVoiceMgr        pointer to synthesizer data
747  * pSynth           pointer to virtual synth
748  * pPolyphonyCount  pointer to variable to receive data
749  *
750  * Outputs:
751  *
752  * Side Effects:
753  *
754  *----------------------------------------------------------------------------
755 */
756 EAS_RESULT VMGetPolyphony (S_VOICE_MGR *pVoiceMgr, S_SYNTH *pSynth, EAS_I32 *pPolyphonyCount);
757 
758 /*----------------------------------------------------------------------------
759  * VMSetPriority()
760  *----------------------------------------------------------------------------
761  * Purpose:
762  * Set the virtual synth priority
763  *
764  * Inputs:
765  * pVoiceMgr        pointer to synthesizer data
766  * priority         new priority
767  * pSynth           pointer to virtual synth
768  *
769  * Outputs:
770  * Returns error code
771  *
772  * Side Effects:
773  *
774  *----------------------------------------------------------------------------
775 */
776 EAS_RESULT VMSetPriority (S_VOICE_MGR *pVoiceMgr, S_SYNTH *pSynth, EAS_I32 priority);
777 
778 /*----------------------------------------------------------------------------
779  * VMGetPriority()
780  *----------------------------------------------------------------------------
781  * Purpose:
782  * Get the virtual synth priority
783  *
784  * Inputs:
785  * pVoiceMgr        pointer to synthesizer data
786  * pPriority        pointer to variable to hold priority
787  * pSynth           pointer to virtual synth
788  *
789  * Outputs:
790  * Returns error code
791  *
792  * Side Effects:
793  *
794  *----------------------------------------------------------------------------
795 */
796 EAS_RESULT VMGetPriority (S_VOICE_MGR *pVoiceMgr, S_SYNTH *pSynth, EAS_I32 *pPriority);
797 
798 /*----------------------------------------------------------------------------
799  * VMSetVolume()
800  *----------------------------------------------------------------------------
801  * Purpose:
802  * Set the master volume for this sequence
803  *
804  * Inputs:
805  * nSynthVolume - the desired master volume
806  * psEASData - pointer to overall EAS data structure
807  *
808  * Outputs:
809  *
810  *
811  * Side Effects:
812  * overrides any previously set master volume from sysex
813  *
814  *----------------------------------------------------------------------------
815 */
816 void VMSetVolume (S_SYNTH *pSynth, EAS_U16 masterVolume);
817 
818 /*----------------------------------------------------------------------------
819  * VMSetPitchBendRange()
820  *----------------------------------------------------------------------------
821  * Set the pitch bend range for the given channel.
822  *----------------------------------------------------------------------------
823 */
824 void VMSetPitchBendRange (S_SYNTH *pSynth, EAS_INT channel, EAS_I16 pitchBendRange);
825 
826 /*----------------------------------------------------------------------------
827  * VMSetEASLib()
828  *----------------------------------------------------------------------------
829  * Purpose:
830  * Sets the pointer to the sound library
831  *
832  * Inputs:
833  * psEASData - pointer to overall EAS data structure
834  *
835  * Outputs:
836  *
837  *----------------------------------------------------------------------------
838 */
839 EAS_RESULT VMSetGlobalEASLib (S_VOICE_MGR *pVoiceMgr, EAS_SNDLIB_HANDLE pEAS);
840 EAS_RESULT VMSetEASLib (S_SYNTH *pSynth, EAS_SNDLIB_HANDLE pEAS);
841 
842 #ifdef DLS_SYNTHESIZER
843 /*----------------------------------------------------------------------------
844  * VMSetDLSLib()
845  *----------------------------------------------------------------------------
846  * Purpose:
847  * Sets the pointer to the sound library
848  *
849  * Inputs:
850  * psEASData - pointer to overall EAS data structure
851  *
852  * Outputs:
853  *
854  *----------------------------------------------------------------------------
855 */
856 EAS_RESULT VMSetGlobalDLSLib (EAS_DATA_HANDLE pEASData, EAS_DLSLIB_HANDLE pDLS);
857 EAS_RESULT VMSetDLSLib (S_SYNTH *pSynth, EAS_DLSLIB_HANDLE pDLS);
858 #endif
859 
860 /*----------------------------------------------------------------------------
861  * VMSetTranposition()
862  *----------------------------------------------------------------------------
863  * Purpose:
864  * Sets the global key transposition used by the synthesizer.
865  * Transposes all melodic instruments up or down by the specified
866  * amount. Range is limited to +/-12 semitones.
867  *
868  * Inputs:
869  * psEASData        - pointer to overall EAS data structure
870  * transposition    - transpose amount (+/-12)
871  *
872  * Outputs:
873  *
874  *
875  * Side Effects:
876  *
877  *----------------------------------------------------------------------------
878 */
879 void VMSetTranposition (S_SYNTH *pSynth, EAS_I32 transposition);
880 
881 /*----------------------------------------------------------------------------
882  * VMGetTranposition()
883  *----------------------------------------------------------------------------
884  * Purpose:
885  * Gets the global key transposition used by the synthesizer.
886  * Transposes all melodic instruments up or down by the specified
887  * amount. Range is limited to +/-12 semitones.
888  *
889  * Inputs:
890  * psEASData - pointer to overall EAS data structure
891  *
892  * Outputs:
893  *
894  *
895  * Side Effects:
896  *
897  *----------------------------------------------------------------------------
898 */
899 void VMGetTranposition (S_SYNTH *pSynth, EAS_I32 *pTransposition);
900 
901 /*----------------------------------------------------------------------------
902  * VMGetNoteCount()
903  *----------------------------------------------------------------------------
904 * Returns the total note count
905 *----------------------------------------------------------------------------
906 */
907 EAS_I32 VMGetNoteCount (S_SYNTH *pSynth);
908 
909 /*----------------------------------------------------------------------------
910  * VMRender()
911  *----------------------------------------------------------------------------
912  * Purpose:
913  * This routine renders a frame of audio
914  *
915  * Inputs:
916  * psEASData        - pointer to overall EAS data structure
917  *
918  * Outputs:
919  * pVoicesRendered  - number of voices rendered this frame
920  *
921  * Side Effects:
922  * sets psMidiObject->m_nMaxWorkloadPerFrame
923  *
924  *----------------------------------------------------------------------------
925 */
926 EAS_RESULT VMRender (S_VOICE_MGR *pVoiceMgr, EAS_I32 numSamples, EAS_I32 *pMixBuffer, EAS_I32 *pVoicesRendered);
927 
928 /*----------------------------------------------------------------------------
929  * VMInitWorkload()
930  *----------------------------------------------------------------------------
931  * Purpose:
932  * Clears the workload counter
933  *
934  * Inputs:
935  * pVoiceMgr            - pointer to instance data
936  *
937  * Outputs:
938  *
939  * Side Effects:
940  *
941  *----------------------------------------------------------------------------
942 */
943 void VMInitWorkload (S_VOICE_MGR *pVoiceMgr);
944 
945 /*----------------------------------------------------------------------------
946  * VMSetWorkload()
947  *----------------------------------------------------------------------------
948  * Purpose:
949  * Sets the max workload for a single frame.
950  *
951  * Inputs:
952  * pVoiceMgr            - pointer to instance data
953  *
954  * Outputs:
955  *
956  * Side Effects:
957  *
958  *----------------------------------------------------------------------------
959 */
960 void VMSetWorkload (S_VOICE_MGR *pVoiceMgr, EAS_I32 maxWorkLoad);
961 
962 /*----------------------------------------------------------------------------
963  * VMCheckWorkload()
964  *----------------------------------------------------------------------------
965  * Purpose:
966  * Checks to see if work load has been exceeded on this frame.
967  *
968  * Inputs:
969  * pVoiceMgr            - pointer to instance data
970  *
971  * Outputs:
972  *
973  * Side Effects:
974  *
975  *----------------------------------------------------------------------------
976 */
977 EAS_BOOL VMCheckWorkload (S_VOICE_MGR *pVoiceMgr);
978 
979 /*----------------------------------------------------------------------------
980  * VMActiveVoices()
981  *----------------------------------------------------------------------------
982  * Purpose:
983  * Returns the number of active voices in the synthesizer.
984  *
985  * Inputs:
986  * pEASData         - pointer to instance data
987  *
988  * Outputs:
989  * Returns the number of active voices
990  *
991  * Side Effects:
992  *
993  *----------------------------------------------------------------------------
994 */
995 EAS_I32 VMActiveVoices (S_SYNTH *pSynth);
996 
997 /*----------------------------------------------------------------------------
998  * VMMIDIShutdown()
999  *----------------------------------------------------------------------------
1000  * Purpose:
1001  * Clean up any Synth related system issues.
1002  *
1003  * Inputs:
1004  * psEASData - pointer to overall EAS data structure
1005  *
1006  * Outputs:
1007  * None
1008  *
1009  * Side Effects:
1010  *
1011  *----------------------------------------------------------------------------
1012 */
1013 void VMMIDIShutdown (S_EAS_DATA *pEASData, S_SYNTH *pSynth);
1014 
1015 /*----------------------------------------------------------------------------
1016  * VMShutdown()
1017  *----------------------------------------------------------------------------
1018  * Purpose:
1019  * Clean up any Synth related system issues.
1020  *
1021  * Inputs:
1022  * psEASData - pointer to overall EAS data structure
1023  *
1024  * Outputs:
1025  * None
1026  *
1027  * Side Effects:
1028  *
1029  *----------------------------------------------------------------------------
1030 */
1031 void VMShutdown (S_EAS_DATA *pEASData);
1032 
1033 #ifdef EXTERNAL_AUDIO
1034 /*----------------------------------------------------------------------------
1035  * EAS_RegExtAudioCallback()
1036  *----------------------------------------------------------------------------
1037  * Register a callback for external audio processing
1038  *----------------------------------------------------------------------------
1039 */
1040 void VMRegExtAudioCallback (S_SYNTH *pSynth, EAS_VOID_PTR pInstData, EAS_EXT_PRG_CHG_FUNC cbProgChgFunc, EAS_EXT_EVENT_FUNC cbEventFunc);
1041 
1042 /*----------------------------------------------------------------------------
1043  * VMGetMIDIControllers()
1044  *----------------------------------------------------------------------------
1045  * Returns the MIDI controller values on the specified channel
1046  *----------------------------------------------------------------------------
1047 */
1048 void VMGetMIDIControllers (S_SYNTH *pSynth, EAS_U8 channel, S_MIDI_CONTROLLERS *pControl);
1049 #endif
1050 
1051 #ifdef _SPLIT_ARCHITECTURE
1052 /*----------------------------------------------------------------------------
1053  * VMStartFrame()
1054  *----------------------------------------------------------------------------
1055  * Purpose:
1056  * Starts an audio frame
1057  *
1058  * Inputs:
1059  *
1060  * Outputs:
1061  *
1062  * Side Effects:
1063  *
1064  *----------------------------------------------------------------------------
1065 */
1066 EAS_BOOL VMStartFrame (S_EAS_DATA *pEASData);
1067 
1068 /*----------------------------------------------------------------------------
1069  * VMEndFrame()
1070  *----------------------------------------------------------------------------
1071  * Purpose:
1072  * Stops an audio frame
1073  *
1074  * Inputs:
1075  *
1076  * Outputs:
1077  *
1078  * Side Effects:
1079  *
1080  *----------------------------------------------------------------------------
1081 */
1082 EAS_BOOL VMEndFrame (S_EAS_DATA *pEASData);
1083 #endif
1084 
1085 #endif /* #ifdef _EAS_VM_PROTOS_H */
1086 
1087