*** empty log message ***
authorclaus
Wed, 12 Jan 1994 20:11:13 +0100
changeset 15 62e2816c87ac
parent 14 ca0b5fbc8131
child 16 0956de6a8c71
*** empty log message ***
SoundStr.st
SoundStream.st
--- a/SoundStr.st	Sun Jan 09 22:24:30 1994 +0100
+++ b/SoundStr.st	Wed Jan 12 20:11:13 1994 +0100
@@ -23,12 +23,13 @@
 sun audio device. On iris default setup is 8 bit mono
 so I can play the standard sound files I have here.
 
-$Header: /cvs/stx/stx/libbasic2/Attic/SoundStr.st,v 1.6 1994-01-08 16:23:49 claus Exp $
+$Header: /cvs/stx/stx/libbasic2/Attic/SoundStr.st,v 1.7 1994-01-12 19:11:13 claus Exp $
 '!
 
 %{
 #ifdef IRIS
 # include <audio.h>
+# define MKAUDIO(o)  (ALport)(_intVal(o))
 #endif
 %}
 
@@ -524,7 +525,7 @@
     ALsetparams(AL_DEFAULT_DEVICE, params, 6);
     p = ALopenport("smallchat", (char *)_stringVal(aMode), config);
     if (p) {
-        _INST(filePointer) = _MKSMALLINT((int) p);
+        _INST(filePointer) = MKOBJ(p);
     } else {
         _INST(filePointer) = nil;
         RETURN (nil);
@@ -611,7 +612,7 @@
             if (_isSmallInteger(count) && _isSmallInteger(start)) {
                 cnt = _intVal(count);
                 offs = _intVal(start) - 1;
-                p = (ALport)(_intVal(_INST(filePointer)));
+                p = MKAUDIO(_INST(filePointer));
 
                 /*
                  * compute number of samples
@@ -658,7 +659,7 @@
             if (_isSmallInteger(count) && _isSmallInteger(start)) {
                 cnt = _intVal(count);
                 offs = _intVal(start) - 1;
-                p = (ALport)(_intVal(_INST(filePointer)));
+                p = MKAUDIO(_INST(filePointer));
                 objSize = _Size(anObject) - OHDR_SIZE;
                 if ((offs >= 0) && (cnt >= 0) && (objSize >= (cnt + offs))) {
                     cp = (char *)_InstPtr(anObject) + OHDR_SIZE + offs;
@@ -691,7 +692,7 @@
     ALport p;
 
     if (_INST(filePointer) != nil) {
-        p = (ALport)(_intVal(_INST(filePointer)));
+        p = MKAUDIO(_INST(filePointer));
         while (ALgetfilled(p) > 0) {
             sginap(1);
         }
@@ -715,7 +716,7 @@
     ].
 %{ 
 #ifdef IRIS
-    ALcloseport( (ALport) (_intVal(_INST(filePointer))) );
+    ALcloseport(MKAUDIO(_INST(filePointer)));
 #endif
 %}
 ! !
@@ -723,7 +724,7 @@
 !SoundStream methodsFor:'sine wave generation'!
 
 tuneTone
-    |buffer numSamples val|
+    |buffer numSamples val scale|
 
     "allocate memory for 1sec playing time"
     numSamples := self sampleRate.
@@ -731,16 +732,18 @@
 
     "fill it with a sine wave"
 
+    scale := 440 * 2 * (Float pi).
     1 to:numSamples do:[:i |
-        val := (440 * 2 * (Float pi) * i / numSamples) sin.
-        val := val * 127 + 128.
-        buffer at:i put:val rounded
+        val := (scale * i / numSamples) sin.
+        val := (val * 127 + 128) rounded.
+        buffer at:i put:val
     ].
 
-    "play 3 seconds"
+    buffer inspect.
+
     1 to:3 do:[:s |
         self nextPutBytes:numSamples from:buffer
     ]
 
-    "SoundStream writing tuneTone synchronizeOutput close"
+    "SoundStream writing tuneTone"
 ! !
--- a/SoundStream.st	Sun Jan 09 22:24:30 1994 +0100
+++ b/SoundStream.st	Wed Jan 12 20:11:13 1994 +0100
@@ -23,12 +23,13 @@
 sun audio device. On iris default setup is 8 bit mono
 so I can play the standard sound files I have here.
 
-$Header: /cvs/stx/stx/libbasic2/SoundStream.st,v 1.6 1994-01-08 16:23:49 claus Exp $
+$Header: /cvs/stx/stx/libbasic2/SoundStream.st,v 1.7 1994-01-12 19:11:13 claus Exp $
 '!
 
 %{
 #ifdef IRIS
 # include <audio.h>
+# define MKAUDIO(o)  (ALport)(_intVal(o))
 #endif
 %}
 
@@ -524,7 +525,7 @@
     ALsetparams(AL_DEFAULT_DEVICE, params, 6);
     p = ALopenport("smallchat", (char *)_stringVal(aMode), config);
     if (p) {
-        _INST(filePointer) = _MKSMALLINT((int) p);
+        _INST(filePointer) = MKOBJ(p);
     } else {
         _INST(filePointer) = nil;
         RETURN (nil);
@@ -611,7 +612,7 @@
             if (_isSmallInteger(count) && _isSmallInteger(start)) {
                 cnt = _intVal(count);
                 offs = _intVal(start) - 1;
-                p = (ALport)(_intVal(_INST(filePointer)));
+                p = MKAUDIO(_INST(filePointer));
 
                 /*
                  * compute number of samples
@@ -658,7 +659,7 @@
             if (_isSmallInteger(count) && _isSmallInteger(start)) {
                 cnt = _intVal(count);
                 offs = _intVal(start) - 1;
-                p = (ALport)(_intVal(_INST(filePointer)));
+                p = MKAUDIO(_INST(filePointer));
                 objSize = _Size(anObject) - OHDR_SIZE;
                 if ((offs >= 0) && (cnt >= 0) && (objSize >= (cnt + offs))) {
                     cp = (char *)_InstPtr(anObject) + OHDR_SIZE + offs;
@@ -691,7 +692,7 @@
     ALport p;
 
     if (_INST(filePointer) != nil) {
-        p = (ALport)(_intVal(_INST(filePointer)));
+        p = MKAUDIO(_INST(filePointer));
         while (ALgetfilled(p) > 0) {
             sginap(1);
         }
@@ -715,7 +716,7 @@
     ].
 %{ 
 #ifdef IRIS
-    ALcloseport( (ALport) (_intVal(_INST(filePointer))) );
+    ALcloseport(MKAUDIO(_INST(filePointer)));
 #endif
 %}
 ! !
@@ -723,7 +724,7 @@
 !SoundStream methodsFor:'sine wave generation'!
 
 tuneTone
-    |buffer numSamples val|
+    |buffer numSamples val scale|
 
     "allocate memory for 1sec playing time"
     numSamples := self sampleRate.
@@ -731,16 +732,18 @@
 
     "fill it with a sine wave"
 
+    scale := 440 * 2 * (Float pi).
     1 to:numSamples do:[:i |
-        val := (440 * 2 * (Float pi) * i / numSamples) sin.
-        val := val * 127 + 128.
-        buffer at:i put:val rounded
+        val := (scale * i / numSamples) sin.
+        val := (val * 127 + 128) rounded.
+        buffer at:i put:val
     ].
 
-    "play 3 seconds"
+    buffer inspect.
+
     1 to:3 do:[:s |
         self nextPutBytes:numSamples from:buffer
     ]
 
-    "SoundStream writing tuneTone synchronizeOutput close"
+    "SoundStream writing tuneTone"
 ! !