Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

exponents need to be a whole number?

26 views
Skip to first unread message

Michael DeBusk

unread,
Dec 1, 2005, 4:02:16 AM12/1/05
to
I'd like to be able to run the following code under OS/2 classic rexx:

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/

ML

unread,
Dec 1, 2005, 8:00:23 AM12/1/05
to

> I'd like to be able to run the following code under OS/2
> classic rexx:

Other than trying to find a mathematical solution, you could
try RexxMath@Hobbes which offers the C pow()-function.

---

ML

unread,
Dec 1, 2005, 8:02:53 AM12/1/05
to

> (While I'm at it, is there a way for Rexx to play a sine wave
> through a PC's sound card?)

I'm not sure if multimedia REXX, which should come with OS/2, has
such a Play()-function available for you?

---

Michael DeBusk

unread,
Dec 1, 2005, 1:24:47 PM12/1/05
to
On 01 Dec 2005 13:02:53 GMT, ML <spam...@hotmai1.com> wrote:

> 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.

Salvador Parra Camacho

unread,
Dec 1, 2005, 3:14:26 PM12/1/05
to
There are several external libraries with mathematical functions for
OS/2:

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

unread,
Dec 1, 2005, 11:21:41 PM12/1/05
to
or repower from: the Album of Algorithms and Techniques for Standard Rexx at
http://www.geocities.com/SiliconValley/Garage/3323/aat/index.html

Richard Brady

Mike Cowlishaw

unread,
Dec 6, 2005, 12:28:34 PM12/6/05
to
For this particular application you don't really need to use the power
operator; just pre-calculate the scale. For example, here's a little player
and a sample caller:

-----
/* 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


Michael DeBusk

unread,
Dec 7, 2005, 2:04:52 AM12/7/05
to
On Tue, 6 Dec 2005 17:28:34 -0000, Mike Cowlishaw <m...@uk.ibm.com> wrote:
> For this particular application you don't really need to use the
> power operator; just pre-calculate the scale. For example, here's a
> little player and a sample caller:

Ingenious. Thanks very much.

YOur little player looks like it could almost read abc notation:

http://staffweb.cms.gre.ac.uk/~c.walshaw/abc/

0 new messages