home *** CD-ROM | disk | FTP | other *** search
- #ifndef sound_H
- #define sound_H
-
- /* C header file for Sound
- * written by DefMod (Sep 7 1994) on Wed Sep 7 21:19:18 1994
- * Copyright © Acorn Computers Ltd, 1994
- */
-
- /*************************************************************************
- * This source file was written by Acorn Computers Limited. It is part *
- * of the OSLib library for writing applications for RISC OS. It may be *
- * used freely in the creation of programs for RISC OS. *
- *************************************************************************/
-
- #ifndef types_H
- #include "types.h"
- #endif
-
- #ifndef os_H
- #include "os.h"
- #endif
-
- /**********************************
- * SWI names and SWI reason codes *
- **********************************/
- #undef Sound_Configure
- #define Sound_Configure 0x40140
- #undef XSound_Configure
- #define XSound_Configure 0x60140
- #undef Sound_Enable
- #define Sound_Enable 0x40141
- #undef XSound_Enable
- #define XSound_Enable 0x60141
- #undef Sound_Stereo
- #define Sound_Stereo 0x40142
- #undef XSound_Stereo
- #define XSound_Stereo 0x60142
- #undef Sound_Speaker
- #define Sound_Speaker 0x40143
- #undef XSound_Speaker
- #define XSound_Speaker 0x60143
- #undef Sound_Volume
- #define Sound_Volume 0x40180
- #undef XSound_Volume
- #define XSound_Volume 0x60180
- #undef Sound_SoundLog
- #define Sound_SoundLog 0x40181
- #undef XSound_SoundLog
- #define XSound_SoundLog 0x60181
- #undef Sound_LogScale
- #define Sound_LogScale 0x40182
- #undef XSound_LogScale
- #define XSound_LogScale 0x60182
- #undef Sound_InstallVoice
- #define Sound_InstallVoice 0x40183
- #undef XSound_InstallVoice
- #define XSound_InstallVoice 0x60183
- #undef SoundInstallVoice_ReadName
- #define SoundInstallVoice_ReadName 0x0
- #undef SoundInstallVoice_AddNamedVoice
- #define SoundInstallVoice_AddNamedVoice 0x1
- #undef SoundInstallVoice_ReadLocalName
- #define SoundInstallVoice_ReadLocalName 0x2
- #undef SoundInstallVoice_ChangeLocalName
- #define SoundInstallVoice_ChangeLocalName 0x3
- #undef Sound_RemoveVoice
- #define Sound_RemoveVoice 0x40184
- #undef XSound_RemoveVoice
- #define XSound_RemoveVoice 0x60184
- #undef Sound_AttachVoice
- #define Sound_AttachVoice 0x40185
- #undef XSound_AttachVoice
- #define XSound_AttachVoice 0x60185
- #undef Sound_ControlPacked
- #define Sound_ControlPacked 0x40186
- #undef XSound_ControlPacked
- #define XSound_ControlPacked 0x60186
- #undef Sound_Tuning
- #define Sound_Tuning 0x40187
- #undef XSound_Tuning
- #define XSound_Tuning 0x60187
- #undef Sound_Pitch
- #define Sound_Pitch 0x40188
- #undef XSound_Pitch
- #define XSound_Pitch 0x60188
- #undef Sound_Control
- #define Sound_Control 0x40189
- #undef XSound_Control
- #define XSound_Control 0x60189
- #undef Sound_AttachNamedVoice
- #define Sound_AttachNamedVoice 0x4018A
- #undef XSound_AttachNamedVoice
- #define XSound_AttachNamedVoice 0x6018A
- #undef Sound_ReadControlBlock
- #define Sound_ReadControlBlock 0x4018B
- #undef XSound_ReadControlBlock
- #define XSound_ReadControlBlock 0x6018B
- #undef Sound_WriteControlBlock
- #define Sound_WriteControlBlock 0x4018C
- #undef XSound_WriteControlBlock
- #define XSound_WriteControlBlock 0x6018C
- #undef Sound_QInit
- #define Sound_QInit 0x401C0
- #undef XSound_QInit
- #define XSound_QInit 0x601C0
- #undef Sound_QSchedule
- #define Sound_QSchedule 0x401C1
- #undef XSound_QSchedule
- #define XSound_QSchedule 0x601C1
- #undef Sound_QRemove
- #define Sound_QRemove 0x401C2
- #undef XSound_QRemove
- #define XSound_QRemove 0x601C2
- #undef Sound_QFree
- #define Sound_QFree 0x401C3
- #undef XSound_QFree
- #define XSound_QFree 0x601C3
- #undef Sound_QSDispatch
- #define Sound_QSDispatch 0x401C4
- #undef XSound_QSDispatch
- #define XSound_QSDispatch 0x601C4
- #undef Sound_QTempo
- #define Sound_QTempo 0x401C5
- #undef XSound_QTempo
- #define XSound_QTempo 0x601C5
- #undef Sound_QBeat
- #define Sound_QBeat 0x401C6
- #undef XSound_QBeat
- #define XSound_QBeat 0x601C6
- #undef Sound_QInterface
- #define Sound_QInterface 0x401C7
- #undef XSound_QInterface
- #define XSound_QInterface 0x601C7
- #undef Service_Sound
- #define Service_Sound 0x54
- #undef Event_StartOfBar
- #define Event_StartOfBar 0xC
-
- /************************************
- * Structure and union declarations *
- ************************************/
- typedef struct sound_log_table sound_log_table;
- typedef struct sound_log_scale_table sound_log_scale_table;
- typedef struct sound_channel_handler sound_channel_handler;
- typedef struct sound_sccb sound_sccb;
- typedef struct sound_scheduler sound_scheduler;
- typedef struct sound_voice_generator sound_voice_generator;
-
- /********************
- * Type definitions *
- ********************/
- struct sound_log_table
- { byte log [8192];
- };
-
- struct sound_log_scale_table
- { byte log_scale [256];
- };
-
- struct sound_channel_handler
- { void *fill_code;
- void *overrun_fixup_code;
- sound_log_table *log_table;
- sound_log_scale_table *log_scale_table;
- };
-
- struct sound_sccb
- { byte amplitude;
- byte voice_no;
- byte voice_instance;
- byte flags;
- int pitch;
- int timbre;
- int buffer_fill_count;
- int r4;
- int r5;
- int r6;
- int r7;
- int r8;
- int reserved [7];
- int available [48];
- };
-
- struct sound_scheduler
- { void *scheduler;
- };
-
- struct sound_voice_generator
- { int fill_code;
- int update_code;
- int gate_on_code;
- int gate_off_code;
- int instantiate_code;
- int free_code;
- int install_code;
- int voice_name_offset;
- };
-
- /************************
- * Constant definitions *
- ************************/
- #define sound_INSTALL_CODE (-390234112)
- #define sound_STATE_READ 0
- #define sound_STATE_OFF 1
- #define sound_STATE_ON 2
-
- /*************************
- * Function declarations *
- *************************/
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- /*************************************************************
- * NOTE: The following functions provide direct access to *
- * the SWI's noted in the function description. *
- * Please read the relevant PRM section for more *
- * information on their input/output parameters. *
- *************************************************************/
-
- /* ------------------------------------------------------------------------
- * Function: sound_configure()
- *
- * Description: Configures the sound system
- *
- * Input: channel_count - value of R0 on entry
- * sample_size - value of R1 on entry
- * sample_period - value of R2 on entry
- * channel_handler - value of R3 on entry
- * scheduler - value of R4 on entry
- *
- * Output: channel_count_out - value of R0 on exit
- * sample_size_out - value of R1 on exit
- * sample_period_out - value of R2 on exit
- * channel_handler_out - value of R3 on exit
- * scheduler_out - value of R4 on exit
- *
- * Other notes: Calls SWI 0x40140.
- */
-
- extern os_error *xsound_configure (int channel_count,
- int sample_size,
- int sample_period,
- sound_channel_handler *channel_handler,
- sound_scheduler *scheduler,
- int *channel_count_out,
- int *sample_size_out,
- int *sample_period_out,
- sound_channel_handler **channel_handler_out,
- sound_scheduler **scheduler_out);
- extern void sound_configure (int channel_count,
- int sample_size,
- int sample_period,
- sound_channel_handler *channel_handler,
- sound_scheduler *scheduler,
- int *channel_count_out,
- int *sample_size_out,
- int *sample_period_out,
- sound_channel_handler **channel_handler_out,
- sound_scheduler **scheduler_out);
-
- /* ------------------------------------------------------------------------
- * Function: sound_enable()
- *
- * Description: Enables or disables the sound system
- *
- * Input: state - value of R0 on entry
- *
- * Output: state_out - value of R0 on exit (X version only)
- *
- * Returns: R0 (non-X version only)
- *
- * Other notes: Calls SWI 0x40141.
- */
-
- extern os_error *xsound_enable (int state,
- int *state_out);
- extern int sound_enable (int state);
-
- /* ------------------------------------------------------------------------
- * Function: sound_stereo()
- *
- * Description: Sets the stereo position of a channel
- *
- * Input: channel_no - value of R0 on entry
- * position - value of R1 on entry
- *
- * Output: position_out - value of R1 on exit (X version only)
- *
- * Returns: R1 (non-X version only)
- *
- * Other notes: Calls SWI 0x40142.
- */
-
- extern os_error *xsound_stereo (int channel_no,
- int position,
- int *position_out);
- extern int sound_stereo (int channel_no,
- int position);
-
- /* ------------------------------------------------------------------------
- * Function: sound_speaker()
- *
- * Description: Enables or disables the speaker(s)
- *
- * Input: state - value of R0 on entry
- *
- * Output: state_out - value of R0 on exit (X version only)
- *
- * Returns: R0 (non-X version only)
- *
- * Other notes: Calls SWI 0x40143.
- */
-
- extern os_error *xsound_speaker (int state,
- int *state_out);
- extern int sound_speaker (int state);
-
- /* ------------------------------------------------------------------------
- * Function: sound_volume()
- *
- * Description: Sets the overall volume of the sound system
- *
- * Input: volume - value of R0 on entry
- *
- * Output: volume_out - value of R0 on exit (X version only)
- *
- * Returns: R0 (non-X version only)
- *
- * Other notes: Calls SWI 0x40180.
- */
-
- extern os_error *xsound_volume (int volume,
- int *volume_out);
- extern int sound_volume (int volume);
-
- /* ------------------------------------------------------------------------
- * Function: sound_sound_log()
- *
- * Description: Converts a signed integer to a signed logarithm, scaling
- * it by volume
- *
- * Input: linear - value of R0 on entry
- *
- * Output: log - value of R0 on exit (X version only)
- *
- * Returns: R0 (non-X version only)
- *
- * Other notes: Calls SWI 0x40181.
- */
-
- extern os_error *xsound_sound_log (int linear,
- int *log);
- extern int sound_sound_log (int linear);
-
- /* ------------------------------------------------------------------------
- * Function: sound_log_scale()
- *
- * Description: Scales a signed logarithm by the current volume setting
- *
- * Input: log - value of R0 on entry
- *
- * Output: linear - value of R0 on exit (X version only)
- *
- * Returns: R0 (non-X version only)
- *
- * Other notes: Calls SWI 0x40182.
- */
-
- extern os_error *xsound_log_scale (int log,
- int *linear);
- extern int sound_log_scale (int log);
-
- /* ------------------------------------------------------------------------
- * Function: sound_install_voice()
- *
- * Description: Adds a voice to the sound system
- *
- * Input: voice_generator - value of R0 on entry
- * voice_no - value of R1 on entry
- *
- * Output: voice_name_out - value of R0 on exit
- * voice_no_out - value of R1 on exit (X version only)
- *
- * Returns: R1 (non-X version only)
- *
- * Other notes: Calls SWI 0x40183.
- */
-
- extern os_error *xsound_install_voice (sound_voice_generator *voice_generator,
- int voice_no,
- char **voice_name_out,
- int *voice_no_out);
- extern int sound_install_voice (sound_voice_generator *voice_generator,
- int voice_no,
- char **voice_name_out);
-
- /* ------------------------------------------------------------------------
- * Function: soundinstallvoice_read_name()
- *
- * Description: Reads the name of the voice installed in the specified
- * slot
- *
- * Input: voice_no - value of R1 on entry
- *
- * Output: voice_name - value of R0 on exit (X version only)
- *
- * Returns: R0 (non-X version only)
- *
- * Other notes: Calls SWI 0x40183 with R0 = 0x0.
- */
-
- extern os_error *xsoundinstallvoice_read_name (int voice_no,
- char **voice_name);
- extern char *soundinstallvoice_read_name (int voice_no);
-
- /* ------------------------------------------------------------------------
- * Function: soundinstallvoice_add_named_voice()
- *
- * Description: Adds a voice to the sound system, specifying its name in
- * the local language
- *
- * Input: voice_no - value of R1 on entry
- * voice_generator - value of R2 on entry
- * voice_name - value of R3 on entry
- *
- * Output: voice_no_out - value of R1 on exit (X version only)
- * voice_name_out - value of R2 on exit
- *
- * Returns: R1 (non-X version only)
- *
- * Other notes: Calls SWI 0x40183 with R0 = 0x1.
- */
-
- extern os_error *xsoundinstallvoice_add_named_voice (int voice_no,
- sound_voice_generator *voice_generator,
- char *voice_name,
- int *voice_no_out,
- char **voice_name_out);
- extern int soundinstallvoice_add_named_voice (int voice_no,
- sound_voice_generator *voice_generator,
- char *voice_name,
- char **voice_name_out);
-
- /* ------------------------------------------------------------------------
- * Function: soundinstallvoice_read_local_name()
- *
- * Description: Reads the name and local name of the voice installed in
- * the specified slot
- *
- * Input: voice_no - value of R1 on entry
- *
- * Output: voice_name_out - value of R2 on exit (X version only)
- * voice_local_name_out - value of R3 on exit
- *
- * Returns: R2 (non-X version only)
- *
- * Other notes: Calls SWI 0x40183 with R0 = 0x2.
- */
-
- extern os_error *xsoundinstallvoice_read_local_name (int voice_no,
- char **voice_name_out,
- char **voice_local_name_out);
- extern char *soundinstallvoice_read_local_name (int voice_no,
- char **voice_local_name_out);
-
- /* ------------------------------------------------------------------------
- * Function: soundinstallvoice_change_local_name()
- *
- * Description: Changes the local name of the voice installed in the
- * specified slot
- *
- * Input: voice_no - value of R1 on entry
- * voice_local_name - value of R3 on entry
- *
- * Other notes: Calls SWI 0x40183 with R0 = 0x3, R2 = 0x0.
- */
-
- extern os_error *xsoundinstallvoice_change_local_name (int voice_no,
- char *voice_local_name);
- extern void soundinstallvoice_change_local_name (int voice_no,
- char *voice_local_name);
-
- /* ------------------------------------------------------------------------
- * Function: sound_remove_voice()
- *
- * Description: Removes a voice from the sound system
- *
- * Input: voice_no - value of R1 on entry
- *
- * Output: voice_name_out - value of R0 on exit
- * voice_no_out - value of R1 on exit (X version only)
- *
- * Returns: R1 (non-X version only)
- *
- * Other notes: Calls SWI 0x40184.
- */
-
- extern os_error *xsound_remove_voice (int voice_no,
- char **voice_name_out,
- int *voice_no_out);
- extern int sound_remove_voice (int voice_no,
- char **voice_name_out);
-
- /* ------------------------------------------------------------------------
- * Function: sound_attach_voice()
- *
- * Description: Attaches a voice to a channel
- *
- * Input: channel_no - value of R0 on entry
- * voice_no - value of R1 on entry
- *
- * Output: channel_no_out - value of R0 on exit
- * voice_no_out - value of R1 on exit
- *
- * Other notes: Calls SWI 0x40185.
- */
-
- extern os_error *xsound_attach_voice (int channel_no,
- int voice_no,
- int *channel_no_out,
- int *voice_no_out);
- extern void sound_attach_voice (int channel_no,
- int voice_no,
- int *channel_no_out,
- int *voice_no_out);
-
- /* ------------------------------------------------------------------------
- * Function: sound_control_packed()
- *
- * Description: Makes an immediate sound
- *
- * Input: amp_and_channel - value of R0 on entry
- * duration_and_pitch - value of R1 on entry
- *
- * Other notes: Calls SWI 0x40186.
- */
-
- extern os_error *xsound_control_packed (bits amp_and_channel,
- bits duration_and_pitch);
- extern void sound_control_packed (bits amp_and_channel,
- bits duration_and_pitch);
-
- /* ------------------------------------------------------------------------
- * Function: sound_tuning()
- *
- * Description: Sets the tuning for the sound system
- *
- * Input: tuning - value of R0 on entry
- *
- * Output: tuning_out - value of R0 on exit (X version only)
- *
- * Returns: R0 (non-X version only)
- *
- * Other notes: Calls SWI 0x40187.
- */
-
- extern os_error *xsound_tuning (int tuning,
- int *tuning_out);
- extern int sound_tuning (int tuning);
-
- /* ------------------------------------------------------------------------
- * Function: sound_pitch()
- *
- * Description: Converts a pitch to internal format (a phase accumulator
- * value)
- *
- * Input: pitch - value of R0 on entry
- *
- * Output: accumulator - value of R0 on exit (X version only)
- *
- * Returns: R0 (non-X version only)
- *
- * Other notes: Calls SWI 0x40188.
- */
-
- extern os_error *xsound_pitch (int pitch,
- int *accumulator);
- extern int sound_pitch (int pitch);
-
- /* ------------------------------------------------------------------------
- * Function: sound_control()
- *
- * Description: Makes an immediate sound
- *
- * Input: channel_no - value of R0 on entry
- * amplitude - value of R1 on entry
- * pitch - value of R2 on entry
- * duration - value of R3 on entry
- *
- * Other notes: Calls SWI 0x40189.
- */
-
- extern os_error *xsound_control (int channel_no,
- int amplitude,
- int pitch,
- int duration);
- extern void sound_control (int channel_no,
- int amplitude,
- int pitch,
- int duration);
-
- /* ------------------------------------------------------------------------
- * Function: sound_attach_named_voice()
- *
- * Description: Attaches a named voice to a channel
- *
- * Input: channel_no - value of R0 on entry
- * voice_name - value of R1 on entry
- *
- * Other notes: Calls SWI 0x4018A.
- */
-
- extern os_error *xsound_attach_named_voice (int channel_no,
- char *voice_name);
- extern void sound_attach_named_voice (int channel_no,
- char *voice_name);
-
- /* ------------------------------------------------------------------------
- * Function: sound_read_control_block()
- *
- * Description: Reads a value from the sound channel control block (SCCB)
- *
- * Input: channel_no - value of R0 on entry
- * offset - value of R1 on entry
- *
- * Output: channel_no_out - value of R0 on exit
- * word - value of R2 on exit
- *
- * Other notes: Calls SWI 0x4018B.
- */
-
- extern os_error *xsound_read_control_block (int channel_no,
- int offset,
- int *channel_no_out,
- int *word);
- extern void sound_read_control_block (int channel_no,
- int offset,
- int *channel_no_out,
- int *word);
-
- /* ------------------------------------------------------------------------
- * Function: sound_write_control_block()
- *
- * Description: Writes a value to the sound channel control block (SCCB)
- *
- * Input: channel_no - value of R0 on entry
- * offset - value of R1 on entry
- * word - value of R2 on entry
- *
- * Output: channel_no_out - value of R0 on exit
- * word_out - value of R2 on exit
- *
- * Other notes: Calls SWI 0x4018C.
- */
-
- extern os_error *xsound_write_control_block (int channel_no,
- int offset,
- int word,
- int *channel_no_out,
- int *word_out);
- extern void sound_write_control_block (int channel_no,
- int offset,
- int word,
- int *channel_no_out,
- int *word_out);
-
- /* ------------------------------------------------------------------------
- * Function: sound_qinit()
- *
- * Description: Initialises the scheduler's event queue
- *
- * Other notes: Calls SWI 0x401C0.
- */
-
- extern os_error *xsound_qinit (void);
- extern void sound_qinit (void);
-
- /* ------------------------------------------------------------------------
- * Function: sound_qschedule()
- *
- * Description: Schedules a sound SWI on the event queue
- *
- * Input: period - value of R0 on entry
- * swi_no - value of R1 on entry
- * swi_r0 - value of R2 on entry
- * swi_r1 - value of R3 on entry
- *
- * Output: failed - value of R0 on exit (X version only)
- *
- * Returns: R0 (non-X version only)
- *
- * Other notes: Calls SWI 0x401C1.
- */
-
- extern os_error *xsound_qschedule (int period,
- int swi_no,
- int swi_r0,
- int swi_r1,
- bool *failed);
- extern bool sound_qschedule (int period,
- int swi_no,
- int swi_r0,
- int swi_r1);
-
- /* ------------------------------------------------------------------------
- * Function: sound_qremove()
- *
- * Description: This call is for use by the scheduler only
- *
- * Other notes: Calls SWI 0x401C2.
- */
-
- extern os_error *xsound_qremove (void);
- extern void sound_qremove (void);
-
- /* ------------------------------------------------------------------------
- * Function: sound_qfree()
- *
- * Description: Returns the minimum number of free slots in the event
- * queue
- *
- * Output: free_count - value of R0 on exit (X version only)
- *
- * Returns: R0 (non-X version only)
- *
- * Other notes: Calls SWI 0x401C3.
- */
-
- extern os_error *xsound_qfree (int *free_count);
- extern int sound_qfree (void);
-
- /* ------------------------------------------------------------------------
- * Function: sound_qtempo()
- *
- * Description: Sets the tempo for the scheduler
- *
- * Input: tempo - value of R0 on entry
- *
- * Output: tempo_out - value of R0 on exit (X version only)
- *
- * Returns: R0 (non-X version only)
- *
- * Other notes: Calls SWI 0x401C5.
- */
-
- extern os_error *xsound_qtempo (int tempo,
- int *tempo_out);
- extern int sound_qtempo (int tempo);
-
- /* ------------------------------------------------------------------------
- * Function: sound_qbeat()
- *
- * Description: Sets or reads the beat counter or bar length
- *
- * Input: bar_length - value of R0 on entry
- *
- * Output: bar_length_out - value of R0 on exit (X version only)
- *
- * Returns: R0 (non-X version only)
- *
- * Other notes: Calls SWI 0x401C6.
- */
-
- extern os_error *xsound_qbeat (int bar_length,
- int *bar_length_out);
- extern int sound_qbeat (int bar_length);
-
- /* ------------------------------------------------------------------------
- * Function: service_sound()
- *
- * Description: Parts of the sound system are starting up or dying
- *
- * Input: part - value of R0 on entry
- *
- * Other notes: Calls SWI 0x30 with R1 = 0x54.
- */
-
- extern os_error *xservice_sound (int part);
- extern void service_sound (int part);
-
- /* ------------------------------------------------------------------------
- * Function: event_start_of_bar()
- *
- * Description: Sound start of bar event
- *
- * Other notes: Calls SWI 0x22 with R0 = 0xC, R1 = 0x2, R2 = 0x0.
- */
-
- extern os_error *xevent_start_of_bar (void);
- extern void event_start_of_bar (void);
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif
-