#FEATURE by exept
authorClaus Gittinger <cg@exept.de>
Sun, 05 Jan 2020 21:30:40 +0100
changeset 5424 9f874a72681c
parent 5423 90f37d96ffb1
child 5425 17cec979acdf
#FEATURE by exept class: SoundStream class comment/format in: #documentation class: SoundStream::DevAudio class comment/format in: #documentation class: SoundStream::IRISAudio class comment/format in: #documentation class: SoundStream::JackAudio changed: #openWithMode:attributes: class: SoundStream::JackAudio class added: #documentation class: SoundStream::PortAudio class comment/format in: #documentation class: SoundStream::Win32DirectSound class comment/format in: #documentation class: SoundStream::Win32WaveSound class comment/format in: #documentation
SoundStream.st
--- a/SoundStream.st	Sun Jan 05 19:03:20 2020 +0100
+++ b/SoundStream.st	Sun Jan 05 21:30:40 2020 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 1993 by Claus Gittinger
 	      All Rights Reserved
@@ -618,18 +620,18 @@
 "
     Preliminary (unfinished) interface to an audio device.
     Currently works with
-	LINUXs
-	SUNs /dev/audio driver
-	IRIX (indy).
+        LINUXs
+        SUNs (and other) /dev/audio driver
+        IRIX (indy).
+        PORTAUDIO (osx).
     On iris, the default setup is for 8 bit mono
     so I can play the standard sound files I have here.
     It needs much more work, for stereo, different sampling rates etc.
 
-    This is an experimental class - its interface & implementation
-    may change in the future.
+    This is an experimental class - its interface & implementation may change in the future.
 
     [author:]
-	Claus Gittinger
+        Claus Gittinger
 "
 ! !
 
@@ -2196,35 +2198,7 @@
 
 documentation
 "
-    documentation to be added.
-
-    class:
-	<a short class summary here, describing what instances represent>
-
-    responsibilities:
-	<describing what my main role is>
-
-    collaborators:
-	<describing with whom and how I talk to>
-
-    API:
-	<public api and main messages>
-
-    example:
-	<a one-line examples on how to use - can also be in a separate example method>
-
-    implementation:
-	<implementation points>
-
-    [author:]
-	exept MBP
-
-    [instance variables:]
-
-    [class variables:]
-
-    [see also:]
-
+    interface to /dev/audio (sun, hpux, linux, ...)
 "
 ! !
 
@@ -3165,35 +3139,7 @@
 
 documentation
 "
-    documentation to be added.
-
-    class:
-	<a short class summary here, describing what instances represent>
-
-    responsibilities:
-	<describing what my main role is>
-
-    collaborators:
-	<describing with whom and how I talk to>
-
-    API:
-	<public api and main messages>
-
-    example:
-	<a one-line examples on how to use - can also be in a separate example method>
-
-    implementation:
-	<implementation points>
-
-    [author:]
-	exept MBP
-
-    [instance variables:]
-
-    [class variables:]
-
-    [see also:]
-
+    interface to the silicon graphics IRIX audio system
 "
 ! !
 
@@ -3462,6 +3408,14 @@
     self errorUnsupportedOperation
 ! !
 
+!SoundStream::JackAudio class methodsFor:'documentation'!
+
+documentation
+"
+    interface to the jack audio system
+"
+! !
+
 !SoundStream::JackAudio class methodsFor:'queries'!
 
 defaultAudioFormat
@@ -3541,39 +3495,40 @@
     ok = false;
 
     if (__isSmallInteger(__INST(numberOfChannels))) {
-	nChannels = __intVal(__INST(numberOfChannels));
+        nChannels = __intVal(__INST(numberOfChannels));
     } else {
-	nChannels = 1;
+        nChannels = 1;
     }
 
     if (__INST(audioFormat) == @symbol(F32)) {
-	bytesPerSample = 4;
+        bytesPerSample = 4;
     } else {
-	fprintf(stderr, "SoundStream [warning]: only f32 supported with jack\n");
-	errorStringOrNil = __MKSTRING("audioFormat must be f32 with jack");
-	goto out;
+        fprintf(stderr, "SoundStream [warning]: only f32 supported with jack\n");
+        errorStringOrNil = __MKSTRING("audioFormat must be f32 with jack");
+        goto out;
     }
 
     if (__isSmallInteger(__INST(sampleRate))) {
-	sampleRate = __intVal(__INST(sampleRate));
+        sampleRate = __intVal(__INST(sampleRate));
     } else {
-	fprintf(stderr, "SoundStream [warning]: using default sampleRate 8000\n");
-	sampleRate = 8000;
+        fprintf(stderr, "SoundStream [warning]: using default sampleRate 8000\n");
+        sampleRate = 8000;
     }
 
     streamData = (struct jackStreamData*)malloc(sizeof(struct jackStreamData));
     if (streamData == NULL) {
-	fprintf(stderr, "SoundStream [warning]: failed to allocate jackStream\n");
-	errorStringOrNil = __MKSTRING("failed to allocate jackStream");
-	goto out;
+        fprintf(stderr, "SoundStream [warning]: failed to allocate jackStream\n");
+        errorStringOrNil = __MKSTRING("failed to allocate jackStream");
+        goto out;
     }
 
     if ((client = jack_client_open ("stx", JackNullOption, NULL)) == 0) {
-	fprintf(stderr, "SoundStream [warning]: client_open\n");
-	free(streamData);
-	errorStringOrNil = __MKSTRING("client_open");
-	goto out;
+        fprintf(stderr, "SoundStream [warning]: client_open\n");
+        free(streamData);
+        errorStringOrNil = __MKSTRING("client_open");
+        goto out;
     }
+    jack_set_process_callback (client, jack_callback, 0);
 
     streamData->jack_client = client;
     INITLOCK(streamData->lock);
@@ -3587,8 +3542,8 @@
     streamData->hasFinished = 0;
 
     {
-	OBJ t;
-	t = __MKEXTERNALADDRESS(streamData); __INST(handle1) = t; __STORE(self, t);
+        OBJ t;
+        t = __MKEXTERNALADDRESS(streamData); __INST(handle1) = t; __STORE(self, t);
     }
     __INST(binary) = true;
 
@@ -3606,14 +3561,13 @@
 
 %}.
     ok == false ifTrue:[
-	lastErrorString := errorStringOrNil.
-	lastErrorNumber := error ? -1.
-	self openError:error.
-	"normally not reached"
-	^ nil.
+        lastErrorString := errorStringOrNil.
+        lastErrorNumber := error ? -1.
+        self openError:error.
+        "normally not reached"
+        ^ nil.
     ].
     self registerForFinalization.
-
 !
 
 reopenStream
@@ -3679,35 +3633,7 @@
 
 documentation
 "
-    documentation to be added.
-
-    class:
-	<a short class summary here, describing what instances represent>
-
-    responsibilities:
-	<describing what my main role is>
-
-    collaborators:
-	<describing with whom and how I talk to>
-
-    API:
-	<public api and main messages>
-
-    example:
-	<a one-line examples on how to use - can also be in a separate example method>
-
-    implementation:
-	<implementation points>
-
-    [author:]
-	exept MBP
-
-    [instance variables:]
-
-    [class variables:]
-
-    [see also:]
-
+    interface to the portaudio library
 "
 ! !
 
@@ -4139,35 +4065,7 @@
 
 documentation
 "
-    documentation to be added.
-
-    class:
-	<a short class summary here, describing what instances represent>
-
-    responsibilities:
-	<describing what my main role is>
-
-    collaborators:
-	<describing with whom and how I talk to>
-
-    API:
-	<public api and main messages>
-
-    example:
-	<a one-line examples on how to use - can also be in a separate example method>
-
-    implementation:
-	<implementation points>
-
-    [author:]
-	exept MBP
-
-    [instance variables:]
-
-    [class variables:]
-
-    [see also:]
-
+    interface to the windows direct sound API
 "
 ! !
 
@@ -4503,35 +4401,7 @@
 
 documentation
 "
-    documentation to be added.
-
-    class:
-	<a short class summary here, describing what instances represent>
-
-    responsibilities:
-	<describing what my main role is>
-
-    collaborators:
-	<describing with whom and how I talk to>
-
-    API:
-	<public api and main messages>
-
-    example:
-	<a one-line examples on how to use - can also be in a separate example method>
-
-    implementation:
-	<implementation points>
-
-    [author:]
-	exept MBP
-
-    [instance variables:]
-
-    [class variables:]
-
-    [see also:]
-
+    interface to the windows wave sound API
 "
 ! !