# HG changeset patch # User Stefan Vogel # Date 831545727 -7200 # Node ID f45bd0d6ea3118124fa1296f954fd7e3740c4c33 # Parent c66a8556b40f9e2cef912be38c95db437b9cbcbb Rename synchronizeOutput --> flush. diff -r c66a8556b40f -r f45bd0d6ea31 SoundStr.st --- a/SoundStr.st Fri May 03 18:08:48 1996 +0200 +++ b/SoundStr.st Wed May 08 10:55:27 1996 +0200 @@ -495,12 +495,10 @@ OperatingSystem getOSType = 'irix' ifFalse:[ ^ super closeFile ]. -%{ -#ifdef IRIS_AUDIO - ALcloseport(_ALportVal(__INST(filePointer))); -#endif -%} -! ! +%{closeFile + "a stream has been collected - close the file" + + OperatingSys}c! ! !SoundStream methodsFor:'mode setting'! @@ -612,48 +610,58 @@ "Modified: 17.11.1995 / 17:47:13 / cg" ! +flush + "wait until all sound has been played" + +%{flush + "wait until all sound has been played" + +%{ +#ifdef IR!flush + {flush + "wait until all sound has been played" + +%{ +#ifdef IRIS_AUDIO + ALpor{flush + "wait until all sound }flush}flush + "wait until all s}flush + "wait until all sound has been played" + +%{ +#ifdef IRIS_AUD! + nextBytes:count into:anObject startingAt:start "read the next count bytes into an object and return the number of bytes read or nil on error. Use with ByteArrays only." +%{nextBytes:count into:{nextBytes:count into:anObject startingAt:start + "read the next count bytes into an object a!nextByt{nextBytes:count int!nextBytes:coun{nextBytes:count into:anObject startingAt:sta{nextBytes:count into:anObject startingAt:start + "read the next count bytes into an object and return the number of + bytes read or nil on error. + Use with ByteArrays only." + +%{ +#ifdef IR{nextBytes:count into:anObject startingAt:start + "read the next count bytes into an object and return the number of + bytes read or nil on error. + Use with ByteArrays only." + +%{ +#ifdef IRIS_AUDIO + { + ALport p;}nextBy}ne}nextB}nex}nextBytes}nextBytes:count into:anObject startingAt:start + "read the next count bytes into an object and return the number of + bytes read or nil on error. + Use with ByteArrays only." + %{ #ifdef IRIS_AUDIO { ALport p; int cnt, offs; - int objSize; - char *cp; - - if (__INST(filePointer) != nil) { - if (__INST(mode) != _writeonly) { - if (__bothSmallInteger(count, start)) { - cnt = _intVal(count); - offs = _intVal(start) - 1; - p = _ALportVal(__INST(filePointer)); - objSize = _Size(anObject) - OHDR_SIZE; - if ((offs >= 0) && (cnt >= 0) && (objSize >= (cnt + offs))) { - cp = (char *)__InstPtr(anObject) + OHDR_SIZE + offs; - if (__INST(bitsPerSample) == __MKSMALLINT(16)) - ALreadsamps(p, cp, cnt / 2); - else - ALreadsamps(p, cp, cnt); - RETURN ( __MKSMALLINT(cnt) ); - } - } - } - } - } -#endif -%} -. - OperatingSystem getOSType = 'irix' ifFalse:[ - ^ super nextPutBytes:count from:anObject startingAt:start - ]. - filePointer isNil ifTrue:[^ self errorNotOpen]. - (mode == #writeonly) ifTrue:[^ self errorWriteOnly]. - self primitiveFailed -! + int ob! nextPutBytes:count from:anObject startingAt:start "write count bytes from an object starting at index start. @@ -661,47 +669,19 @@ Redefined, since IRIS audio library cannot be used with stdio. (at least I dont know). Use with ByteArrays only." -%{ -#ifdef IRIS_AUDIO - { - ALport p; - int cnt, offs; - int objSize; - char *cp; - - if (__INST(filePointer) != nil) { - if (__INST(mode) != _readonly) { - if (__bothSmallInteger(count, start)) { - cnt = _intVal(count); - offs = _intVal(start) - 1; - p = _ALportVal(__INST(filePointer)); - - /* - * compute number of samples - */ - objSize = _Size(anObject) - OHDR_SIZE; - if ( (offs >= 0) && (cnt >= 0) && (objSize >= (cnt + offs)) ) { - cp = (char *)__InstPtr(anObject) + OHDR_SIZE + offs; - if (__INST(bitsPerSample) == __MKSMALLINT(16)) - ALwritesamps(p, cp, cnt / 2); - else - ALwritesamps(p, cp, cnt); - RETURN ( __MKSMALLINT(cnt) ); - } - } - } - } - } -#endif -%} -. - OperatingSystem getOSType = 'irix' ifFalse:[ - ^ super nextPutBytes:count from:anObject startingAt:start - ]. - filePointer isNil ifTrue:[^ self errorNotOpen]. - (mode == #readonly) ifTrue:[^ self errorReadOnly]. - self primitiveFailed -! +%{nextPutBytes:count fr{nextPutBytes:count from:anObject startingAt:start + "write count bytes from an object starti!nextPut{nextPutBytes:count !nextPutBytes:{nextPutBytes:count from:anObject startingAt:{nextPutBytes:count from:anObject startingAt:start + "write count bytes from an object starting at index start. + return the number of bytes written or nil on error. + Redefined, since IRIS audio library cannot be used with stdio. + {nextPutBytes:count from:anObject startingAt:start + "write count bytes from an object starting at index start. + return the number of bytes written or nil on error. + Redefined, since IRIS audio library cannot be use}nextPu}ne}nextP}nex}nextPutBy}nextPutBytes:count from:anObject startingAt:start + "write count bytes from an object starting at index start. + return the number of bytes written or nil on error. + Redefined, since IRIS audio library cannot be used with stdio. + (at lea! openWithMode:aMode OperatingSystem getOSType = 'irix' ifFalse:[ @@ -713,6 +693,20 @@ self error:'invalid mode'. ^ nil ]. +%{openWithMode:aMode + {openWithMode:aMode + OperatingSystem getOSType = 'irix{openWithMode:aMode + OperatingSystem getOSType = 'irix' ifFalse:[ + "its a regula}openWithMode:aMode + OperatingSystem getOSType = 'irix' ifFalse:[ + "its a regular file open" + ^ super openWithMode:aMode + ]. + + ((aMode = 'r') or:[aMode = 'w']) ifFalse:[ + self error:'invalid mode'. + ^ nil + ]. %{ #ifdef IRIS_AUDIO { @@ -728,85 +722,42 @@ if (__INST(numberOfChannels) == __MKSMALLINT(2)) ALsetchannels(config, AL_STEREO); else - ALsetchannels(config, AL_MONO); - if (__INST(bitsPerSample) == __MKSMALLINT(16)) - ALsetwidth(config, AL_SAMPLE_16); - else - ALsetwidth(config, AL_SAMPLE_8); - - if (__isSmallInteger(__INST(sampleRate))) - params[3] = params[5] = _intVal(__INST(sampleRate)); + ALset{openWithMode:aMode + OperatingSystem g}openWi{openWithMode:aMode + OperatingSystem getOSType}openWithMode:aMode + OperatingSystem getOSType = 'irix' ifFalse:[ + "its a regular file open" + ^ super openWithMode:aMode + ]. - ALsetparams(AL_DEFAULT_DEVICE, params, 6); - p = ALopenport("smallchat", (char *)_stringVal(aMode), config); - if (p) { - __INST(filePointer) = __MKOBJ(p); - } else { - __INST(filePointer) = nil; - RETURN (nil); - } - __INST(binary) = true; + ((aMode = 'r') or:[aMode = 'w']) ifFalse:[ + {openWithMode:aMode + OperatingSystem getOSType = 'irix' ifFalse:[ + "its a regular file open" + ^ super openWithMode:aMode + ]. - ALfreeconfig(config); - /* - * get the parameters actually installed - */ - config = ALgetconfig(p); - switch (ALgetchannels(config)) { - default: - /* cannot happen */ - case AL_MONO: - __INST(numberOfChannels) = __MKSMALLINT(1); - break; - case AL_STEREO: - __INST(numberOfChannels) = __MKSMALLINT(2); - break; - } - switch (ALgetwidth(config)) { - default: - /* cannot happen */ - case AL_SAMPLE_8: - __INST(bitsPerSample) = __MKSMALLINT(8); - break; - case AL_SAMPLE_16: - __INST(bitsPerSample) = __MKSMALLINT(16); - break; - case AL_SAMPLE_24: - __INST(bitsPerSample) = __MKSMALLINT(24); - break; - } - ALgetparams(AL_DEFAULT_DEVICE, params, 6); - __INST(sampleRate) = __MKSMALLINT(params[3]); + ((aMode = 'r') or:[aMode = 'w']) ifFalse:[ + self error:'inv}openWithMode:aMode + OperatingS{openWithMode:aMode + OperatingSystem getOSType = 'irix' ifFalse:[ + "its a regular file open" + ^ super openWithMode:aMode + ]. - ALfreeconfig(config); - } -#endif -%} -. - ^ self -! - -synchronizeOutput - "wait until all sound has been played" - -%{ + ((aMode = 'r') or:[aMode = 'w']) ifFalse:[ + self error:'invalid mode'. + ^ nil + ]. +%{ #ifdef IRIS_AUDIO - ALport p; - - if (__INST(filePointer) != nil) { - p = _ALportVal(__INST(filePointer)); - while (ALgetfilled(p) > 0) { - sginap(1); - } - } -#endif -%} -. + { + ALconfig config; + ALpor}openWithMode:aMode OperatingSystem getOSType = 'irix' ifFalse:[ - "dont know how to wait" - ]. - ^ self -! ! + "its a regular file open" + ^ super openWithMode:aMode + }openWithM}openWithMode:a! ! !SoundStream methodsFor:'sine wave generation'! @@ -838,4 +789,4 @@ !SoundStream class methodsFor:'documentation'! version -^ '$Header: /cvs/stx/stx/libbasic2/Attic/SoundStr.st,v 1.21 1996-04-25 17:01:43 cg Exp $'! ! +^ '$Header: /cvs/stx/stx/libbasic2/Attic/SoundStr.st,v 1.22 1996-05-08 08:55:27 stefan Exp $'! ! diff -r c66a8556b40f -r f45bd0d6ea31 SoundStream.st --- a/SoundStream.st Fri May 03 18:08:48 1996 +0200 +++ b/SoundStream.st Wed May 08 10:55:27 1996 +0200 @@ -495,12 +495,10 @@ OperatingSystem getOSType = 'irix' ifFalse:[ ^ super closeFile ]. -%{ -#ifdef IRIS_AUDIO - ALcloseport(_ALportVal(__INST(filePointer))); -#endif -%} -! ! +%{closeFile + "a stream has been collected - close the file" + + OperatingSys}c! ! !SoundStream methodsFor:'mode setting'! @@ -612,48 +610,58 @@ "Modified: 17.11.1995 / 17:47:13 / cg" ! +flush + "wait until all sound has been played" + +%{flush + "wait until all sound has been played" + +%{ +#ifdef IR!flush + {flush + "wait until all sound has been played" + +%{ +#ifdef IRIS_AUDIO + ALpor{flush + "wait until all sound }flush}flush + "wait until all s}flush + "wait until all sound has been played" + +%{ +#ifdef IRIS_AUD! + nextBytes:count into:anObject startingAt:start "read the next count bytes into an object and return the number of bytes read or nil on error. Use with ByteArrays only." +%{nextBytes:count into:{nextBytes:count into:anObject startingAt:start + "read the next count bytes into an object a!nextByt{nextBytes:count int!nextBytes:coun{nextBytes:count into:anObject startingAt:sta{nextBytes:count into:anObject startingAt:start + "read the next count bytes into an object and return the number of + bytes read or nil on error. + Use with ByteArrays only." + +%{ +#ifdef IR{nextBytes:count into:anObject startingAt:start + "read the next count bytes into an object and return the number of + bytes read or nil on error. + Use with ByteArrays only." + +%{ +#ifdef IRIS_AUDIO + { + ALport p;}nextBy}ne}nextB}nex}nextBytes}nextBytes:count into:anObject startingAt:start + "read the next count bytes into an object and return the number of + bytes read or nil on error. + Use with ByteArrays only." + %{ #ifdef IRIS_AUDIO { ALport p; int cnt, offs; - int objSize; - char *cp; - - if (__INST(filePointer) != nil) { - if (__INST(mode) != _writeonly) { - if (__bothSmallInteger(count, start)) { - cnt = _intVal(count); - offs = _intVal(start) - 1; - p = _ALportVal(__INST(filePointer)); - objSize = _Size(anObject) - OHDR_SIZE; - if ((offs >= 0) && (cnt >= 0) && (objSize >= (cnt + offs))) { - cp = (char *)__InstPtr(anObject) + OHDR_SIZE + offs; - if (__INST(bitsPerSample) == __MKSMALLINT(16)) - ALreadsamps(p, cp, cnt / 2); - else - ALreadsamps(p, cp, cnt); - RETURN ( __MKSMALLINT(cnt) ); - } - } - } - } - } -#endif -%} -. - OperatingSystem getOSType = 'irix' ifFalse:[ - ^ super nextPutBytes:count from:anObject startingAt:start - ]. - filePointer isNil ifTrue:[^ self errorNotOpen]. - (mode == #writeonly) ifTrue:[^ self errorWriteOnly]. - self primitiveFailed -! + int ob! nextPutBytes:count from:anObject startingAt:start "write count bytes from an object starting at index start. @@ -661,47 +669,19 @@ Redefined, since IRIS audio library cannot be used with stdio. (at least I dont know). Use with ByteArrays only." -%{ -#ifdef IRIS_AUDIO - { - ALport p; - int cnt, offs; - int objSize; - char *cp; - - if (__INST(filePointer) != nil) { - if (__INST(mode) != _readonly) { - if (__bothSmallInteger(count, start)) { - cnt = _intVal(count); - offs = _intVal(start) - 1; - p = _ALportVal(__INST(filePointer)); - - /* - * compute number of samples - */ - objSize = _Size(anObject) - OHDR_SIZE; - if ( (offs >= 0) && (cnt >= 0) && (objSize >= (cnt + offs)) ) { - cp = (char *)__InstPtr(anObject) + OHDR_SIZE + offs; - if (__INST(bitsPerSample) == __MKSMALLINT(16)) - ALwritesamps(p, cp, cnt / 2); - else - ALwritesamps(p, cp, cnt); - RETURN ( __MKSMALLINT(cnt) ); - } - } - } - } - } -#endif -%} -. - OperatingSystem getOSType = 'irix' ifFalse:[ - ^ super nextPutBytes:count from:anObject startingAt:start - ]. - filePointer isNil ifTrue:[^ self errorNotOpen]. - (mode == #readonly) ifTrue:[^ self errorReadOnly]. - self primitiveFailed -! +%{nextPutBytes:count fr{nextPutBytes:count from:anObject startingAt:start + "write count bytes from an object starti!nextPut{nextPutBytes:count !nextPutBytes:{nextPutBytes:count from:anObject startingAt:{nextPutBytes:count from:anObject startingAt:start + "write count bytes from an object starting at index start. + return the number of bytes written or nil on error. + Redefined, since IRIS audio library cannot be used with stdio. + {nextPutBytes:count from:anObject startingAt:start + "write count bytes from an object starting at index start. + return the number of bytes written or nil on error. + Redefined, since IRIS audio library cannot be use}nextPu}ne}nextP}nex}nextPutBy}nextPutBytes:count from:anObject startingAt:start + "write count bytes from an object starting at index start. + return the number of bytes written or nil on error. + Redefined, since IRIS audio library cannot be used with stdio. + (at lea! openWithMode:aMode OperatingSystem getOSType = 'irix' ifFalse:[ @@ -713,6 +693,20 @@ self error:'invalid mode'. ^ nil ]. +%{openWithMode:aMode + {openWithMode:aMode + OperatingSystem getOSType = 'irix{openWithMode:aMode + OperatingSystem getOSType = 'irix' ifFalse:[ + "its a regula}openWithMode:aMode + OperatingSystem getOSType = 'irix' ifFalse:[ + "its a regular file open" + ^ super openWithMode:aMode + ]. + + ((aMode = 'r') or:[aMode = 'w']) ifFalse:[ + self error:'invalid mode'. + ^ nil + ]. %{ #ifdef IRIS_AUDIO { @@ -728,85 +722,42 @@ if (__INST(numberOfChannels) == __MKSMALLINT(2)) ALsetchannels(config, AL_STEREO); else - ALsetchannels(config, AL_MONO); - if (__INST(bitsPerSample) == __MKSMALLINT(16)) - ALsetwidth(config, AL_SAMPLE_16); - else - ALsetwidth(config, AL_SAMPLE_8); - - if (__isSmallInteger(__INST(sampleRate))) - params[3] = params[5] = _intVal(__INST(sampleRate)); + ALset{openWithMode:aMode + OperatingSystem g}openWi{openWithMode:aMode + OperatingSystem getOSType}openWithMode:aMode + OperatingSystem getOSType = 'irix' ifFalse:[ + "its a regular file open" + ^ super openWithMode:aMode + ]. - ALsetparams(AL_DEFAULT_DEVICE, params, 6); - p = ALopenport("smallchat", (char *)_stringVal(aMode), config); - if (p) { - __INST(filePointer) = __MKOBJ(p); - } else { - __INST(filePointer) = nil; - RETURN (nil); - } - __INST(binary) = true; + ((aMode = 'r') or:[aMode = 'w']) ifFalse:[ + {openWithMode:aMode + OperatingSystem getOSType = 'irix' ifFalse:[ + "its a regular file open" + ^ super openWithMode:aMode + ]. - ALfreeconfig(config); - /* - * get the parameters actually installed - */ - config = ALgetconfig(p); - switch (ALgetchannels(config)) { - default: - /* cannot happen */ - case AL_MONO: - __INST(numberOfChannels) = __MKSMALLINT(1); - break; - case AL_STEREO: - __INST(numberOfChannels) = __MKSMALLINT(2); - break; - } - switch (ALgetwidth(config)) { - default: - /* cannot happen */ - case AL_SAMPLE_8: - __INST(bitsPerSample) = __MKSMALLINT(8); - break; - case AL_SAMPLE_16: - __INST(bitsPerSample) = __MKSMALLINT(16); - break; - case AL_SAMPLE_24: - __INST(bitsPerSample) = __MKSMALLINT(24); - break; - } - ALgetparams(AL_DEFAULT_DEVICE, params, 6); - __INST(sampleRate) = __MKSMALLINT(params[3]); + ((aMode = 'r') or:[aMode = 'w']) ifFalse:[ + self error:'inv}openWithMode:aMode + OperatingS{openWithMode:aMode + OperatingSystem getOSType = 'irix' ifFalse:[ + "its a regular file open" + ^ super openWithMode:aMode + ]. - ALfreeconfig(config); - } -#endif -%} -. - ^ self -! - -synchronizeOutput - "wait until all sound has been played" - -%{ + ((aMode = 'r') or:[aMode = 'w']) ifFalse:[ + self error:'invalid mode'. + ^ nil + ]. +%{ #ifdef IRIS_AUDIO - ALport p; - - if (__INST(filePointer) != nil) { - p = _ALportVal(__INST(filePointer)); - while (ALgetfilled(p) > 0) { - sginap(1); - } - } -#endif -%} -. + { + ALconfig config; + ALpor}openWithMode:aMode OperatingSystem getOSType = 'irix' ifFalse:[ - "dont know how to wait" - ]. - ^ self -! ! + "its a regular file open" + ^ super openWithMode:aMode + }openWithM}openWithMode:a! ! !SoundStream methodsFor:'sine wave generation'! @@ -838,4 +789,4 @@ !SoundStream class methodsFor:'documentation'! version -^ '$Header: /cvs/stx/stx/libbasic2/SoundStream.st,v 1.21 1996-04-25 17:01:43 cg Exp $'! ! +^ '$Header: /cvs/stx/stx/libbasic2/SoundStream.st,v 1.22 1996-05-08 08:55:27 stefan Exp $'! !