home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 1 / RISC_DISC_1.iso / pd_share / code / oslib / h / sound < prev    next >
Encoding:
Text File  |  1994-09-07  |  24.2 KB  |  799 lines

  1. #ifndef sound_H
  2. #define sound_H
  3.  
  4. /* C header file for Sound
  5.  * written by DefMod (Sep  7 1994) on Wed Sep  7 21:19:18 1994
  6.  * Copyright © Acorn Computers Ltd, 1994
  7.  */
  8.  
  9. /*************************************************************************
  10.  * This source file was written by Acorn Computers Limited. It is part   *
  11.  * of the OSLib library for writing applications for RISC OS. It may be  *
  12.  * used freely in the creation of programs for RISC OS.                  *
  13.  *************************************************************************/
  14.  
  15. #ifndef types_H
  16.    #include "types.h"
  17. #endif
  18.  
  19. #ifndef os_H
  20.    #include "os.h"
  21. #endif
  22.  
  23. /**********************************
  24.  * SWI names and SWI reason codes *
  25.  **********************************/
  26. #undef  Sound_Configure
  27. #define Sound_Configure                         0x40140
  28. #undef  XSound_Configure
  29. #define XSound_Configure                        0x60140
  30. #undef  Sound_Enable
  31. #define Sound_Enable                            0x40141
  32. #undef  XSound_Enable
  33. #define XSound_Enable                           0x60141
  34. #undef  Sound_Stereo
  35. #define Sound_Stereo                            0x40142
  36. #undef  XSound_Stereo
  37. #define XSound_Stereo                           0x60142
  38. #undef  Sound_Speaker
  39. #define Sound_Speaker                           0x40143
  40. #undef  XSound_Speaker
  41. #define XSound_Speaker                          0x60143
  42. #undef  Sound_Volume
  43. #define Sound_Volume                            0x40180
  44. #undef  XSound_Volume
  45. #define XSound_Volume                           0x60180
  46. #undef  Sound_SoundLog
  47. #define Sound_SoundLog                          0x40181
  48. #undef  XSound_SoundLog
  49. #define XSound_SoundLog                         0x60181
  50. #undef  Sound_LogScale
  51. #define Sound_LogScale                          0x40182
  52. #undef  XSound_LogScale
  53. #define XSound_LogScale                         0x60182
  54. #undef  Sound_InstallVoice
  55. #define Sound_InstallVoice                      0x40183
  56. #undef  XSound_InstallVoice
  57. #define XSound_InstallVoice                     0x60183
  58. #undef  SoundInstallVoice_ReadName
  59. #define SoundInstallVoice_ReadName              0x0
  60. #undef  SoundInstallVoice_AddNamedVoice
  61. #define SoundInstallVoice_AddNamedVoice         0x1
  62. #undef  SoundInstallVoice_ReadLocalName
  63. #define SoundInstallVoice_ReadLocalName         0x2
  64. #undef  SoundInstallVoice_ChangeLocalName
  65. #define SoundInstallVoice_ChangeLocalName       0x3
  66. #undef  Sound_RemoveVoice
  67. #define Sound_RemoveVoice                       0x40184
  68. #undef  XSound_RemoveVoice
  69. #define XSound_RemoveVoice                      0x60184
  70. #undef  Sound_AttachVoice
  71. #define Sound_AttachVoice                       0x40185
  72. #undef  XSound_AttachVoice
  73. #define XSound_AttachVoice                      0x60185
  74. #undef  Sound_ControlPacked
  75. #define Sound_ControlPacked                     0x40186
  76. #undef  XSound_ControlPacked
  77. #define XSound_ControlPacked                    0x60186
  78. #undef  Sound_Tuning
  79. #define Sound_Tuning                            0x40187
  80. #undef  XSound_Tuning
  81. #define XSound_Tuning                           0x60187
  82. #undef  Sound_Pitch
  83. #define Sound_Pitch                             0x40188
  84. #undef  XSound_Pitch
  85. #define XSound_Pitch                            0x60188
  86. #undef  Sound_Control
  87. #define Sound_Control                           0x40189
  88. #undef  XSound_Control
  89. #define XSound_Control                          0x60189
  90. #undef  Sound_AttachNamedVoice
  91. #define Sound_AttachNamedVoice                  0x4018A
  92. #undef  XSound_AttachNamedVoice
  93. #define XSound_AttachNamedVoice                 0x6018A
  94. #undef  Sound_ReadControlBlock
  95. #define Sound_ReadControlBlock                  0x4018B
  96. #undef  XSound_ReadControlBlock
  97. #define XSound_ReadControlBlock                 0x6018B
  98. #undef  Sound_WriteControlBlock
  99. #define Sound_WriteControlBlock                 0x4018C
  100. #undef  XSound_WriteControlBlock
  101. #define XSound_WriteControlBlock                0x6018C
  102. #undef  Sound_QInit
  103. #define Sound_QInit                             0x401C0
  104. #undef  XSound_QInit
  105. #define XSound_QInit                            0x601C0
  106. #undef  Sound_QSchedule
  107. #define Sound_QSchedule                         0x401C1
  108. #undef  XSound_QSchedule
  109. #define XSound_QSchedule                        0x601C1
  110. #undef  Sound_QRemove
  111. #define Sound_QRemove                           0x401C2
  112. #undef  XSound_QRemove
  113. #define XSound_QRemove                          0x601C2
  114. #undef  Sound_QFree
  115. #define Sound_QFree                             0x401C3
  116. #undef  XSound_QFree
  117. #define XSound_QFree                            0x601C3
  118. #undef  Sound_QSDispatch
  119. #define Sound_QSDispatch                        0x401C4
  120. #undef  XSound_QSDispatch
  121. #define XSound_QSDispatch                       0x601C4
  122. #undef  Sound_QTempo
  123. #define Sound_QTempo                            0x401C5
  124. #undef  XSound_QTempo
  125. #define XSound_QTempo                           0x601C5
  126. #undef  Sound_QBeat
  127. #define Sound_QBeat                             0x401C6
  128. #undef  XSound_QBeat
  129. #define XSound_QBeat                            0x601C6
  130. #undef  Sound_QInterface
  131. #define Sound_QInterface                        0x401C7
  132. #undef  XSound_QInterface
  133. #define XSound_QInterface                       0x601C7
  134. #undef  Service_Sound
  135. #define Service_Sound                           0x54
  136. #undef  Event_StartOfBar
  137. #define Event_StartOfBar                        0xC
  138.  
  139. /************************************
  140.  * Structure and union declarations *
  141.  ************************************/
  142. typedef struct sound_log_table                  sound_log_table;
  143. typedef struct sound_log_scale_table            sound_log_scale_table;
  144. typedef struct sound_channel_handler            sound_channel_handler;
  145. typedef struct sound_sccb                       sound_sccb;
  146. typedef struct sound_scheduler                  sound_scheduler;
  147. typedef struct sound_voice_generator            sound_voice_generator;
  148.  
  149. /********************
  150.  * Type definitions *
  151.  ********************/
  152. struct sound_log_table
  153.    {  byte log [8192];
  154.    };
  155.  
  156. struct sound_log_scale_table
  157.    {  byte log_scale [256];
  158.    };
  159.  
  160. struct sound_channel_handler
  161.    {  void *fill_code;
  162.       void *overrun_fixup_code;
  163.       sound_log_table *log_table;
  164.       sound_log_scale_table *log_scale_table;
  165.    };
  166.  
  167. struct sound_sccb
  168.    {  byte amplitude;
  169.       byte voice_no;
  170.       byte voice_instance;
  171.       byte flags;
  172.       int pitch;
  173.       int timbre;
  174.       int buffer_fill_count;
  175.       int r4;
  176.       int r5;
  177.       int r6;
  178.       int r7;
  179.       int r8;
  180.       int reserved [7];
  181.       int available [48];
  182.    };
  183.  
  184. struct sound_scheduler
  185.    {  void *scheduler;
  186.    };
  187.  
  188. struct sound_voice_generator
  189.    {  int fill_code;
  190.       int update_code;
  191.       int gate_on_code;
  192.       int gate_off_code;
  193.       int instantiate_code;
  194.       int free_code;
  195.       int install_code;
  196.       int voice_name_offset;
  197.    };
  198.  
  199. /************************
  200.  * Constant definitions *
  201.  ************************/
  202. #define sound_INSTALL_CODE                      (-390234112)
  203. #define sound_STATE_READ                        0
  204. #define sound_STATE_OFF                         1
  205. #define sound_STATE_ON                          2
  206.  
  207. /*************************
  208.  * Function declarations *
  209.  *************************/
  210.  
  211. #ifdef __cplusplus
  212.    extern "C" {
  213. #endif
  214.  
  215. /*************************************************************
  216.  * NOTE: The following functions provide direct access to    *
  217.  *       the SWI's noted in the function description.        *
  218.  *       Please read the relevant PRM section for more       *
  219.  *       information on their input/output parameters.       *
  220.  *************************************************************/
  221.  
  222. /* ------------------------------------------------------------------------
  223.  * Function:      sound_configure()
  224.  *
  225.  * Description:   Configures the sound system
  226.  *
  227.  * Input:         channel_count - value of R0 on entry
  228.  *                sample_size - value of R1 on entry
  229.  *                sample_period - value of R2 on entry
  230.  *                channel_handler - value of R3 on entry
  231.  *                scheduler - value of R4 on entry
  232.  *
  233.  * Output:        channel_count_out - value of R0 on exit
  234.  *                sample_size_out - value of R1 on exit
  235.  *                sample_period_out - value of R2 on exit
  236.  *                channel_handler_out - value of R3 on exit
  237.  *                scheduler_out - value of R4 on exit
  238.  *
  239.  * Other notes:   Calls SWI 0x40140.
  240.  */
  241.  
  242. extern os_error *xsound_configure (int channel_count,
  243.       int sample_size,
  244.       int sample_period,
  245.       sound_channel_handler *channel_handler,
  246.       sound_scheduler *scheduler,
  247.       int *channel_count_out,
  248.       int *sample_size_out,
  249.       int *sample_period_out,
  250.       sound_channel_handler **channel_handler_out,
  251.       sound_scheduler **scheduler_out);
  252. extern void sound_configure (int channel_count,
  253.       int sample_size,
  254.       int sample_period,
  255.       sound_channel_handler *channel_handler,
  256.       sound_scheduler *scheduler,
  257.       int *channel_count_out,
  258.       int *sample_size_out,
  259.       int *sample_period_out,
  260.       sound_channel_handler **channel_handler_out,
  261.       sound_scheduler **scheduler_out);
  262.  
  263. /* ------------------------------------------------------------------------
  264.  * Function:      sound_enable()
  265.  *
  266.  * Description:   Enables or disables the sound system
  267.  *
  268.  * Input:         state - value of R0 on entry
  269.  *
  270.  * Output:        state_out - value of R0 on exit (X version only)
  271.  *
  272.  * Returns:       R0 (non-X version only)
  273.  *
  274.  * Other notes:   Calls SWI 0x40141.
  275.  */
  276.  
  277. extern os_error *xsound_enable (int state,
  278.       int *state_out);
  279. extern int sound_enable (int state);
  280.  
  281. /* ------------------------------------------------------------------------
  282.  * Function:      sound_stereo()
  283.  *
  284.  * Description:   Sets the stereo position of a channel
  285.  *
  286.  * Input:         channel_no - value of R0 on entry
  287.  *                position - value of R1 on entry
  288.  *
  289.  * Output:        position_out - value of R1 on exit (X version only)
  290.  *
  291.  * Returns:       R1 (non-X version only)
  292.  *
  293.  * Other notes:   Calls SWI 0x40142.
  294.  */
  295.  
  296. extern os_error *xsound_stereo (int channel_no,
  297.       int position,
  298.       int *position_out);
  299. extern int sound_stereo (int channel_no,
  300.       int position);
  301.  
  302. /* ------------------------------------------------------------------------
  303.  * Function:      sound_speaker()
  304.  *
  305.  * Description:   Enables or disables the speaker(s)
  306.  *
  307.  * Input:         state - value of R0 on entry
  308.  *
  309.  * Output:        state_out - value of R0 on exit (X version only)
  310.  *
  311.  * Returns:       R0 (non-X version only)
  312.  *
  313.  * Other notes:   Calls SWI 0x40143.
  314.  */
  315.  
  316. extern os_error *xsound_speaker (int state,
  317.       int *state_out);
  318. extern int sound_speaker (int state);
  319.  
  320. /* ------------------------------------------------------------------------
  321.  * Function:      sound_volume()
  322.  *
  323.  * Description:   Sets the overall volume of the sound system
  324.  *
  325.  * Input:         volume - value of R0 on entry
  326.  *
  327.  * Output:        volume_out - value of R0 on exit (X version only)
  328.  *
  329.  * Returns:       R0 (non-X version only)
  330.  *
  331.  * Other notes:   Calls SWI 0x40180.
  332.  */
  333.  
  334. extern os_error *xsound_volume (int volume,
  335.       int *volume_out);
  336. extern int sound_volume (int volume);
  337.  
  338. /* ------------------------------------------------------------------------
  339.  * Function:      sound_sound_log()
  340.  *
  341.  * Description:   Converts a signed integer to a signed logarithm, scaling
  342.  *                it by volume
  343.  *
  344.  * Input:         linear - value of R0 on entry
  345.  *
  346.  * Output:        log - value of R0 on exit (X version only)
  347.  *
  348.  * Returns:       R0 (non-X version only)
  349.  *
  350.  * Other notes:   Calls SWI 0x40181.
  351.  */
  352.  
  353. extern os_error *xsound_sound_log (int linear,
  354.       int *log);
  355. extern int sound_sound_log (int linear);
  356.  
  357. /* ------------------------------------------------------------------------
  358.  * Function:      sound_log_scale()
  359.  *
  360.  * Description:   Scales a signed logarithm by the current volume setting
  361.  *
  362.  * Input:         log - value of R0 on entry
  363.  *
  364.  * Output:        linear - value of R0 on exit (X version only)
  365.  *
  366.  * Returns:       R0 (non-X version only)
  367.  *
  368.  * Other notes:   Calls SWI 0x40182.
  369.  */
  370.  
  371. extern os_error *xsound_log_scale (int log,
  372.       int *linear);
  373. extern int sound_log_scale (int log);
  374.  
  375. /* ------------------------------------------------------------------------
  376.  * Function:      sound_install_voice()
  377.  *
  378.  * Description:   Adds a voice to the sound system
  379.  *
  380.  * Input:         voice_generator - value of R0 on entry
  381.  *                voice_no - value of R1 on entry
  382.  *
  383.  * Output:        voice_name_out - value of R0 on exit
  384.  *                voice_no_out - value of R1 on exit (X version only)
  385.  *
  386.  * Returns:       R1 (non-X version only)
  387.  *
  388.  * Other notes:   Calls SWI 0x40183.
  389.  */
  390.  
  391. extern os_error *xsound_install_voice (sound_voice_generator *voice_generator,
  392.       int voice_no,
  393.       char **voice_name_out,
  394.       int *voice_no_out);
  395. extern int sound_install_voice (sound_voice_generator *voice_generator,
  396.       int voice_no,
  397.       char **voice_name_out);
  398.  
  399. /* ------------------------------------------------------------------------
  400.  * Function:      soundinstallvoice_read_name()
  401.  *
  402.  * Description:   Reads the name of the voice installed in the specified
  403.  *                slot
  404.  *
  405.  * Input:         voice_no - value of R1 on entry
  406.  *
  407.  * Output:        voice_name - value of R0 on exit (X version only)
  408.  *
  409.  * Returns:       R0 (non-X version only)
  410.  *
  411.  * Other notes:   Calls SWI 0x40183 with R0 = 0x0.
  412.  */
  413.  
  414. extern os_error *xsoundinstallvoice_read_name (int voice_no,
  415.       char **voice_name);
  416. extern char *soundinstallvoice_read_name (int voice_no);
  417.  
  418. /* ------------------------------------------------------------------------
  419.  * Function:      soundinstallvoice_add_named_voice()
  420.  *
  421.  * Description:   Adds a voice to the sound system, specifying its name in
  422.  *                the local language
  423.  *
  424.  * Input:         voice_no - value of R1 on entry
  425.  *                voice_generator - value of R2 on entry
  426.  *                voice_name - value of R3 on entry
  427.  *
  428.  * Output:        voice_no_out - value of R1 on exit (X version only)
  429.  *                voice_name_out - value of R2 on exit
  430.  *
  431.  * Returns:       R1 (non-X version only)
  432.  *
  433.  * Other notes:   Calls SWI 0x40183 with R0 = 0x1.
  434.  */
  435.  
  436. extern os_error *xsoundinstallvoice_add_named_voice (int voice_no,
  437.       sound_voice_generator *voice_generator,
  438.       char *voice_name,
  439.       int *voice_no_out,
  440.       char **voice_name_out);
  441. extern int soundinstallvoice_add_named_voice (int voice_no,
  442.       sound_voice_generator *voice_generator,
  443.       char *voice_name,
  444.       char **voice_name_out);
  445.  
  446. /* ------------------------------------------------------------------------
  447.  * Function:      soundinstallvoice_read_local_name()
  448.  *
  449.  * Description:   Reads the name and local name of the voice installed in
  450.  *                the specified slot
  451.  *
  452.  * Input:         voice_no - value of R1 on entry
  453.  *
  454.  * Output:        voice_name_out - value of R2 on exit (X version only)
  455.  *                voice_local_name_out - value of R3 on exit
  456.  *
  457.  * Returns:       R2 (non-X version only)
  458.  *
  459.  * Other notes:   Calls SWI 0x40183 with R0 = 0x2.
  460.  */
  461.  
  462. extern os_error *xsoundinstallvoice_read_local_name (int voice_no,
  463.       char **voice_name_out,
  464.       char **voice_local_name_out);
  465. extern char *soundinstallvoice_read_local_name (int voice_no,
  466.       char **voice_local_name_out);
  467.  
  468. /* ------------------------------------------------------------------------
  469.  * Function:      soundinstallvoice_change_local_name()
  470.  *
  471.  * Description:   Changes the local name of the voice installed in the
  472.  *                specified slot
  473.  *
  474.  * Input:         voice_no - value of R1 on entry
  475.  *                voice_local_name - value of R3 on entry
  476.  *
  477.  * Other notes:   Calls SWI 0x40183 with R0 = 0x3, R2 = 0x0.
  478.  */
  479.  
  480. extern os_error *xsoundinstallvoice_change_local_name (int voice_no,
  481.       char *voice_local_name);
  482. extern void soundinstallvoice_change_local_name (int voice_no,
  483.       char *voice_local_name);
  484.  
  485. /* ------------------------------------------------------------------------
  486.  * Function:      sound_remove_voice()
  487.  *
  488.  * Description:   Removes a voice from the sound system
  489.  *
  490.  * Input:         voice_no - value of R1 on entry
  491.  *
  492.  * Output:        voice_name_out - value of R0 on exit
  493.  *                voice_no_out - value of R1 on exit (X version only)
  494.  *
  495.  * Returns:       R1 (non-X version only)
  496.  *
  497.  * Other notes:   Calls SWI 0x40184.
  498.  */
  499.  
  500. extern os_error *xsound_remove_voice (int voice_no,
  501.       char **voice_name_out,
  502.       int *voice_no_out);
  503. extern int sound_remove_voice (int voice_no,
  504.       char **voice_name_out);
  505.  
  506. /* ------------------------------------------------------------------------
  507.  * Function:      sound_attach_voice()
  508.  *
  509.  * Description:   Attaches a voice to a channel
  510.  *
  511.  * Input:         channel_no - value of R0 on entry
  512.  *                voice_no - value of R1 on entry
  513.  *
  514.  * Output:        channel_no_out - value of R0 on exit
  515.  *                voice_no_out - value of R1 on exit
  516.  *
  517.  * Other notes:   Calls SWI 0x40185.
  518.  */
  519.  
  520. extern os_error *xsound_attach_voice (int channel_no,
  521.       int voice_no,
  522.       int *channel_no_out,
  523.       int *voice_no_out);
  524. extern void sound_attach_voice (int channel_no,
  525.       int voice_no,
  526.       int *channel_no_out,
  527.       int *voice_no_out);
  528.  
  529. /* ------------------------------------------------------------------------
  530.  * Function:      sound_control_packed()
  531.  *
  532.  * Description:   Makes an immediate sound
  533.  *
  534.  * Input:         amp_and_channel - value of R0 on entry
  535.  *                duration_and_pitch - value of R1 on entry
  536.  *
  537.  * Other notes:   Calls SWI 0x40186.
  538.  */
  539.  
  540. extern os_error *xsound_control_packed (bits amp_and_channel,
  541.       bits duration_and_pitch);
  542. extern void sound_control_packed (bits amp_and_channel,
  543.       bits duration_and_pitch);
  544.  
  545. /* ------------------------------------------------------------------------
  546.  * Function:      sound_tuning()
  547.  *
  548.  * Description:   Sets the tuning for the sound system
  549.  *
  550.  * Input:         tuning - value of R0 on entry
  551.  *
  552.  * Output:        tuning_out - value of R0 on exit (X version only)
  553.  *
  554.  * Returns:       R0 (non-X version only)
  555.  *
  556.  * Other notes:   Calls SWI 0x40187.
  557.  */
  558.  
  559. extern os_error *xsound_tuning (int tuning,
  560.       int *tuning_out);
  561. extern int sound_tuning (int tuning);
  562.  
  563. /* ------------------------------------------------------------------------
  564.  * Function:      sound_pitch()
  565.  *
  566.  * Description:   Converts a pitch to internal format (a phase accumulator
  567.  *                value)
  568.  *
  569.  * Input:         pitch - value of R0 on entry
  570.  *
  571.  * Output:        accumulator - value of R0 on exit (X version only)
  572.  *
  573.  * Returns:       R0 (non-X version only)
  574.  *
  575.  * Other notes:   Calls SWI 0x40188.
  576.  */
  577.  
  578. extern os_error *xsound_pitch (int pitch,
  579.       int *accumulator);
  580. extern int sound_pitch (int pitch);
  581.  
  582. /* ------------------------------------------------------------------------
  583.  * Function:      sound_control()
  584.  *
  585.  * Description:   Makes an immediate sound
  586.  *
  587.  * Input:         channel_no - value of R0 on entry
  588.  *                amplitude - value of R1 on entry
  589.  *                pitch - value of R2 on entry
  590.  *                duration - value of R3 on entry
  591.  *
  592.  * Other notes:   Calls SWI 0x40189.
  593.  */
  594.  
  595. extern os_error *xsound_control (int channel_no,
  596.       int amplitude,
  597.       int pitch,
  598.       int duration);
  599. extern void sound_control (int channel_no,
  600.       int amplitude,
  601.       int pitch,
  602.       int duration);
  603.  
  604. /* ------------------------------------------------------------------------
  605.  * Function:      sound_attach_named_voice()
  606.  *
  607.  * Description:   Attaches a named voice to a channel
  608.  *
  609.  * Input:         channel_no - value of R0 on entry
  610.  *                voice_name - value of R1 on entry
  611.  *
  612.  * Other notes:   Calls SWI 0x4018A.
  613.  */
  614.  
  615. extern os_error *xsound_attach_named_voice (int channel_no,
  616.       char *voice_name);
  617. extern void sound_attach_named_voice (int channel_no,
  618.       char *voice_name);
  619.  
  620. /* ------------------------------------------------------------------------
  621.  * Function:      sound_read_control_block()
  622.  *
  623.  * Description:   Reads a value from the sound channel control block (SCCB)
  624.  *
  625.  * Input:         channel_no - value of R0 on entry
  626.  *                offset - value of R1 on entry
  627.  *
  628.  * Output:        channel_no_out - value of R0 on exit
  629.  *                word - value of R2 on exit
  630.  *
  631.  * Other notes:   Calls SWI 0x4018B.
  632.  */
  633.  
  634. extern os_error *xsound_read_control_block (int channel_no,
  635.       int offset,
  636.       int *channel_no_out,
  637.       int *word);
  638. extern void sound_read_control_block (int channel_no,
  639.       int offset,
  640.       int *channel_no_out,
  641.       int *word);
  642.  
  643. /* ------------------------------------------------------------------------
  644.  * Function:      sound_write_control_block()
  645.  *
  646.  * Description:   Writes a value to the sound channel control block (SCCB)
  647.  *
  648.  * Input:         channel_no - value of R0 on entry
  649.  *                offset - value of R1 on entry
  650.  *                word - value of R2 on entry
  651.  *
  652.  * Output:        channel_no_out - value of R0 on exit
  653.  *                word_out - value of R2 on exit
  654.  *
  655.  * Other notes:   Calls SWI 0x4018C.
  656.  */
  657.  
  658. extern os_error *xsound_write_control_block (int channel_no,
  659.       int offset,
  660.       int word,
  661.       int *channel_no_out,
  662.       int *word_out);
  663. extern void sound_write_control_block (int channel_no,
  664.       int offset,
  665.       int word,
  666.       int *channel_no_out,
  667.       int *word_out);
  668.  
  669. /* ------------------------------------------------------------------------
  670.  * Function:      sound_qinit()
  671.  *
  672.  * Description:   Initialises the scheduler's event queue
  673.  *
  674.  * Other notes:   Calls SWI 0x401C0.
  675.  */
  676.  
  677. extern os_error *xsound_qinit (void);
  678. extern void sound_qinit (void);
  679.  
  680. /* ------------------------------------------------------------------------
  681.  * Function:      sound_qschedule()
  682.  *
  683.  * Description:   Schedules a sound SWI on the event queue
  684.  *
  685.  * Input:         period - value of R0 on entry
  686.  *                swi_no - value of R1 on entry
  687.  *                swi_r0 - value of R2 on entry
  688.  *                swi_r1 - value of R3 on entry
  689.  *
  690.  * Output:        failed - value of R0 on exit (X version only)
  691.  *
  692.  * Returns:       R0 (non-X version only)
  693.  *
  694.  * Other notes:   Calls SWI 0x401C1.
  695.  */
  696.  
  697. extern os_error *xsound_qschedule (int period,
  698.       int swi_no,
  699.       int swi_r0,
  700.       int swi_r1,
  701.       bool *failed);
  702. extern bool sound_qschedule (int period,
  703.       int swi_no,
  704.       int swi_r0,
  705.       int swi_r1);
  706.  
  707. /* ------------------------------------------------------------------------
  708.  * Function:      sound_qremove()
  709.  *
  710.  * Description:   This call is for use by the scheduler only
  711.  *
  712.  * Other notes:   Calls SWI 0x401C2.
  713.  */
  714.  
  715. extern os_error *xsound_qremove (void);
  716. extern void sound_qremove (void);
  717.  
  718. /* ------------------------------------------------------------------------
  719.  * Function:      sound_qfree()
  720.  *
  721.  * Description:   Returns the minimum number of free slots in the event
  722.  *                queue
  723.  *
  724.  * Output:        free_count - value of R0 on exit (X version only)
  725.  *
  726.  * Returns:       R0 (non-X version only)
  727.  *
  728.  * Other notes:   Calls SWI 0x401C3.
  729.  */
  730.  
  731. extern os_error *xsound_qfree (int *free_count);
  732. extern int sound_qfree (void);
  733.  
  734. /* ------------------------------------------------------------------------
  735.  * Function:      sound_qtempo()
  736.  *
  737.  * Description:   Sets the tempo for the scheduler
  738.  *
  739.  * Input:         tempo - value of R0 on entry
  740.  *
  741.  * Output:        tempo_out - value of R0 on exit (X version only)
  742.  *
  743.  * Returns:       R0 (non-X version only)
  744.  *
  745.  * Other notes:   Calls SWI 0x401C5.
  746.  */
  747.  
  748. extern os_error *xsound_qtempo (int tempo,
  749.       int *tempo_out);
  750. extern int sound_qtempo (int tempo);
  751.  
  752. /* ------------------------------------------------------------------------
  753.  * Function:      sound_qbeat()
  754.  *
  755.  * Description:   Sets or reads the beat counter or bar length
  756.  *
  757.  * Input:         bar_length - value of R0 on entry
  758.  *
  759.  * Output:        bar_length_out - value of R0 on exit (X version only)
  760.  *
  761.  * Returns:       R0 (non-X version only)
  762.  *
  763.  * Other notes:   Calls SWI 0x401C6.
  764.  */
  765.  
  766. extern os_error *xsound_qbeat (int bar_length,
  767.       int *bar_length_out);
  768. extern int sound_qbeat (int bar_length);
  769.  
  770. /* ------------------------------------------------------------------------
  771.  * Function:      service_sound()
  772.  *
  773.  * Description:   Parts of the sound system are starting up or dying
  774.  *
  775.  * Input:         part - value of R0 on entry
  776.  *
  777.  * Other notes:   Calls SWI 0x30 with R1 = 0x54.
  778.  */
  779.  
  780. extern os_error *xservice_sound (int part);
  781. extern void service_sound (int part);
  782.  
  783. /* ------------------------------------------------------------------------
  784.  * Function:      event_start_of_bar()
  785.  *
  786.  * Description:   Sound start of bar event
  787.  *
  788.  * Other notes:   Calls SWI 0x22 with R0 = 0xC, R1 = 0x2, R2 = 0x0.
  789.  */
  790.  
  791. extern os_error *xevent_start_of_bar (void);
  792. extern void event_start_of_bar (void);
  793.  
  794. #ifdef __cplusplus
  795.    }
  796. #endif
  797.  
  798. #endif
  799.