DO i = 36 TO 107
SAY FORMAT(8.1758 * (2 ** (i/12)), 6, 2)
END
It should look like:
65.41
69.30
73.42
77.78
82.41
...and so on.
I cannot do this, though, because exponents have to be whole numbers.
It only works if I step by 12. (DO i = 36 TO 107 BY 12)
Is there a way to get my desired result in Rexx?
(The output is a list of the frequencies of musical notes, starting
with C 65.41 and ending with B 3591.07.)
(While I'm at it, is there a way for Rexx to play a sine wave through a
PC's sound card?)
Thanks for any assistance.
--
Michael DeBusk, Co-Conspirator to Make the World a Better Place
I am a pineapple * http://home.earthlink.net/~debu4335/
Other than trying to find a mathematical solution, you could
try RexxMath@Hobbes which offers the C pow()-function.
---
I'm not sure if multimedia REXX, which should come with OS/2, has
such a Play()-function available for you?
---
> I'm not sure if multimedia REXX, which should come with OS/2, has
> such a Play()-function available for you?
It lets me play an existing audio stream, but not to create one.
1. REXX libraries:
a) RXXMATH v1.3 by John Brock (arbitrary precision):
http://hobbes.nmsu.edu/pub/os2/dev/rexx/rxxmath.zip
2. DLLs:
a) RxMathFn by Patrick J. Mueller (uses strings "nan" and "infinity"
as result
when needed):
http://www.tavi.co.uk/os2pages/ews/rxmath.zip
b) RXU v1.a by Dave Boll:
http://hobbes.nmsu.edu/pub/os2/dev/rexx/rxu1a.zip
c) REXXMATH v1.0 by Zhitao Zeng (includes several "unusual"
functions such
as hypot( x, y ), j0( x ), gamma( x )):
http://hobbes.nmsu.edu/pub/os2/dev/rexx/rexxmath.zip
d) "The Rexx Math Bumper Pack" by Patrick TJ McPhee (multiplatform,
open source, includes RXXMATH):
http://home.interlog.com/~ptjm/regmath100.zip
You can create a WAV file with the multimedia system of OS/2, but
recording it (see "record.cmd"). The REXX access to the multimedia API
of OS/2 is very limited.
You can manipulate WAV files with RxWav:
http://hobbes.nmsu.edu/pub/os2/dev/rexx/rxwav.zip
Best regards:
Salvador Parra Camacho
Richard Brady
-----
/* Calculate and Play a tune */
/* Notation: notes are as follows this comment ('C'=middle C) */
/* May be prefixed by length (one character: */
/* : quarter note */
/* . half note */
/* 1 full note (default) */
/* 2 double note etc. */
/* MFC 198x */
numeric digits 10
/* Next number is twelfth root of 2, as there are 12 semitones/octave */
ratio=1.0594630944 /* Good for 9 or 10 digits working */
time=300 /* Standard note length */
a=440/2 /* Concert pitch A, less one octave */
pitch.1=a
do i=2 to 25
last=i-1
pitch.i=pitch.last*ratio
sound.i=format(pitch.i,,0)
end
notes='A- A#- B- C C# D D# E F F# G G# A A# B',
'C+ C#+ D+ D#+ E+ F+ F#+ G+ G#+ A+'
arg line
do while line<>''
parse var line note line
parse var note len +1 rest
select
when len='.' then do; length=0.5; note=rest; end
when len=':' then do; length=0.25; note=rest; end
when datatype(len)='CHAR' then length=1
otherwise parse var note length +1 note
end
i=wordpos(note,notes)
if i=0 then say 'Eh? (Note "'note'"?)'
else call beep sound.i, time*length
end
return
-----
/* Play baa-baa */
tune ='c c g g .a .b .c+ .a 2g',
'f f e e d d 2c',
'g .g .g f f e .e .e 2d g .g .g .f .g .a .f e .d .d 2c'
call play tune
exit rc
Ingenious. Thanks very much.
YOur little player looks like it could almost read abc notation:
http://staffweb.cms.gre.ac.uk/~c.walshaw/abc/