RISCOS.com

www.riscos.com Technical Support:
Programmer's Reference Manual

 

WaveSynth


Introduction

WaveSynth is a module that provides a voice generator which is used for the default system bell.

In RISC OS 2 WaveSynth provided a SWI for its own internal use. This has since been removed.

For more information about the use of sound in RISC OS, refer to the The Sound system.

Example programs

You can create new wavetables for use with WaveSynth, for example:

REM > OrganVoice
OUTFILE$="Organ01"
OUT=OPENOUT OUTFILE$
BPUT#OUT,"!WT:Organ"+STRING$(7,CHR$0);
sizeptr=PTR#OUT
PROCW(0)
FORI%=1TO8:PROCW(8):NEXT
PROCW(13):PROCW(0):PROCW(0)
PROCHDR
size=EXT#OUT
PTR#OUT=sizeptr:PROCW(size)
CLOSE#OUT
REM Pass local name Orgel as parameter on command line
*RMREINIT WAVESYNTH ORGAN01 Orgel
END
DEFPROCW(X%)
LOCALI%
FORI%=1TO4:BPUT#OUT,X%:X%=X%>>8:NEXT
ENDPROC
DEFFNW
RESTORE
DATA 1,1, 0.8,2, 0.6,4, 0.4,8, 0.2,16: REM amplitude,frequency
DATA 0,0
M=0
REPEAT
 READ A$,H$:A=EVALA$
 IF A>0 THEN M+=A
UNTIL A=0
M=&7FFFFFFF/M
RESTORE
B=0
REPEAT
 READ A$,H$:A=EVALA$:H=EVALH$
 IF A>0 THEN B+=FNSIN(A*M,H)
UNTIL A=0
=B
DEFFNSIN(A,F)=A*SIN(F*2*PI*s%/256)
DEFPROCHDR
MODE0
ORIGIN0,512
MOVE0,0
RESTORE+0
FORI%=1TO14:READJ$:PROCW(EVALJ$):NEXT
PTR#OUT=256
FOR s%=0 TO 255
 B%=FNW
 SYS "Sound_SoundLog",B% TO wave%
 DRAW s%*4,B%>>22
 BPUT#OUT,wave%
NEXT
ENDPROC
REM offset 64 (index 8)
REM descriptor 8 (ATTACK)
DATA &0000007F + (1<<9)
DATA &00090001
REM descriptor 9 (DECAY)
DATA &000000F0 + (31<<9)
DATA &000A0001
REM descriptor 10 (SUS a)
DATA &00000080 + (500<<9)
DATA &000E0001
REM descriptor 11 (SUS b)
DATA &000000DF + (25<<9)
DATA &000A0001
REM descriptor 12 (SUSTAIN)
DATA &00000000 + (&FFFFF<<9)
DATA &000D0002
REM descriptor 13 (release)
DATA &00000080 + (1<<9)
DATA &000E0001
REM descriptor 14 (Dead)
DATA 0
DATA 0.

You can then load the new wavetable into WaveSynth as a module initialisation parameter, eg:

REM > Source
obj$="<Obey$Dir>.!RunImage"
DIM MC%1000,L%-1
FOR I%=8 TO 10 STEP 2
P%=MC%
[OPTI%
.start
 MOV R0, #14
 ADR R1, instantiation
 SWI "XOS_Module"
 MOV PC, R14
.instantiation
 ; Pass local name Orgel as parameter on command line
 EQUS "WaveSynth%Organ <Obey$Dir>.Organ01 Orgel"+CHR$0
]:NEXT
OSCLI "Save "+obj$+" "+STR$~start+" "+STR$~P%
OSCLI "SetType "+obj$+" &FFC"
OSCLI "Stamp "+obj$

The facility shown in the above examples for specifying a local name was introduced in RISC OS 3.

This edition Copyright © 3QD Developments Ltd 2015
Last Edit: Tue,03 Nov 2015