--- a/SoundStream.st Sat Jan 04 01:49:16 2020 +0100
+++ b/SoundStream.st Sat Jan 04 01:50:41 2020 +0100
@@ -2,7 +2,7 @@
"
COPYRIGHT (c) 1993 by Claus Gittinger
- All Rights Reserved
+ All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
@@ -16,47 +16,47 @@
"{ NameSpace: Smalltalk }"
FileStream subclass:#SoundStream
- instanceVariableNames:'sampleRate numberOfChannels bitsPerSample audioFormat handle1
- handle2 bufferOffset bufferSize lastErrorString fragmentSize
- openMode openAttributes'
- classVariableNames:'IsInitialized UnsupportedOperationSignal ConcreteClass'
- poolDictionaries:''
- category:'Streams-External'
+ instanceVariableNames:'sampleRate numberOfChannels bitsPerSample audioFormat handle1
+ handle2 bufferOffset bufferSize lastErrorString fragmentSize
+ openMode openAttributes'
+ classVariableNames:'IsInitialized UnsupportedOperationSignal ConcreteClass'
+ poolDictionaries:''
+ category:'Streams-External'
!
SoundStream subclass:#DevAudio
- instanceVariableNames:''
- classVariableNames:''
- poolDictionaries:''
- privateIn:SoundStream
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ privateIn:SoundStream
!
SoundStream subclass:#IRISAudio
- instanceVariableNames:''
- classVariableNames:''
- poolDictionaries:''
- privateIn:SoundStream
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ privateIn:SoundStream
!
SoundStream subclass:#PortAudio
- instanceVariableNames:''
- classVariableNames:''
- poolDictionaries:''
- privateIn:SoundStream
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ privateIn:SoundStream
!
SoundStream subclass:#Win32DirectSound
- instanceVariableNames:''
- classVariableNames:''
- poolDictionaries:''
- privateIn:SoundStream
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ privateIn:SoundStream
!
SoundStream subclass:#Win32WaveSound
- instanceVariableNames:''
- classVariableNames:''
- poolDictionaries:''
- privateIn:SoundStream
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ privateIn:SoundStream
!
!SoundStream primitiveDefinitions!
@@ -315,14 +315,14 @@
waveCallBack(HWAVE waveHandle, UINT msg, DWORD_PTR inst, DWORD_PTR p1, DWORD_PTR p2)
{
if (msg == MM_WOM_DONE) {
- struct buf *bp = (struct buf *)p1;
-
- EnterCriticalSection(&free_list_lock);
- bp->next = free_list;
- free_list = bp;
- free_buffers++;
- SetEvent(free_buffer_event);
- LeaveCriticalSection(&free_list_lock);
+ struct buf *bp = (struct buf *)p1;
+
+ EnterCriticalSection(&free_list_lock);
+ bp->next = free_list;
+ free_list = bp;
+ free_buffers++;
+ SetEvent(free_buffer_event);
+ LeaveCriticalSection(&free_list_lock);
}
}
@@ -357,10 +357,10 @@
*/
static int
paCallback( const void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- const PaStreamCallbackTimeInfo* timeInfo,
- PaStreamCallbackFlags statusFlags,
- void *userData )
+ unsigned long framesPerBuffer,
+ const PaStreamCallbackTimeInfo* timeInfo,
+ PaStreamCallbackFlags statusFlags,
+ void *userData )
{
struct paStreamData *paStreamData = (struct paStreamData *)userData;
struct paBuffer *paBuffer = paStreamData->currentBuffer;
@@ -373,66 +373,66 @@
offsetInBuffer = paStreamData->readOffset;
again:
if (paBuffer != NULL) {
- nBytesLeftInBuffer = paBuffer->bufferSize - offsetInBuffer;
- if (DEBUGGING) {
- fprintf(stderr, "pa: Stream Callback (%d from %p; next: %p last: %p)\n",
- nBytesLeftInBuffer, paBuffer, paBuffer->nextBuffer, paStreamData->lastBuffer);
- }
+ nBytesLeftInBuffer = paBuffer->bufferSize - offsetInBuffer;
+ if (DEBUGGING) {
+ fprintf(stderr, "pa: Stream Callback (%d from %p; next: %p last: %p)\n",
+ nBytesLeftInBuffer, paBuffer, paBuffer->nextBuffer, paStreamData->lastBuffer);
+ }
} else {
- nBytesLeftInBuffer = 0;
+ nBytesLeftInBuffer = 0;
}
if (nBytesLeftInBuffer >= nBytesToOutput) {
- memcpy(outputBuffer, paBuffer->sampleData+offsetInBuffer, nBytesToOutput);
- nSent = nBytesToOutput;
- if (DEBUGGING) {
- fprintf(stderr, "pa: %d from buffer\n", nSent);
- }
- nBytesToOutput = 0;
+ memcpy(outputBuffer, paBuffer->sampleData+offsetInBuffer, nBytesToOutput);
+ nSent = nBytesToOutput;
+ if (DEBUGGING) {
+ fprintf(stderr, "pa: %d from buffer\n", nSent);
+ }
+ nBytesToOutput = 0;
} else {
- nSent = nBytesLeftInBuffer;
- if (nSent > 0) {
- memcpy(outputBuffer, paBuffer->sampleData+offsetInBuffer, nBytesLeftInBuffer);
- if (DEBUGGING) {
- fprintf(stderr, "pa: %d from buffer\n", nBytesLeftInBuffer);
- }
- nBytesToOutput -= nSent;
- offsetInBuffer += nBytesLeftInBuffer;
- }
+ nSent = nBytesLeftInBuffer;
+ if (nSent > 0) {
+ memcpy(outputBuffer, paBuffer->sampleData+offsetInBuffer, nBytesLeftInBuffer);
+ if (DEBUGGING) {
+ fprintf(stderr, "pa: %d from buffer\n", nBytesLeftInBuffer);
+ }
+ nBytesToOutput -= nSent;
+ offsetInBuffer += nBytesLeftInBuffer;
+ }
}
if (paBuffer != NULL) {
- paStreamData->readOffset += nSent;
- if (paStreamData->readOffset >= paBuffer->bufferSize) {
- LOCK(paStreamData->lock);
- // next buffer
- paStreamData->readOffset = 0;
- paStreamData->currentBuffer = paBuffer->nextBuffer;
- // this buffer onto freeList
- paBuffer->nextBuffer = paStreamData->freeList;
- paStreamData->freeList = paBuffer;
- if (DEBUGGING) {
- fprintf(stderr, "pa: put on freelist: %p\n", paBuffer);
- }
- if (paStreamData->currentBuffer == NULL) {
- if (DEBUGGING) {
- fprintf(stderr, "pa: done with last buffer\n");
- }
- paStreamData->lastBuffer = NULL;
- retVal = paComplete;
- }
- UNLOCK(paStreamData->lock);
- if (nBytesToOutput > 0) {
- if (paStreamData->currentBuffer == NULL) {
- memset(outputBuffer+offsetInBuffer, 0, nBytesToOutput);
- } else {
- paBuffer = paStreamData->currentBuffer;
- offsetInBuffer = 0;
- if (DEBUGGING) {
- fprintf(stderr, "pa: %d more\n", nBytesToOutput);
- }
- goto again;
- }
- }
- }
+ paStreamData->readOffset += nSent;
+ if (paStreamData->readOffset >= paBuffer->bufferSize) {
+ LOCK(paStreamData->lock);
+ // next buffer
+ paStreamData->readOffset = 0;
+ paStreamData->currentBuffer = paBuffer->nextBuffer;
+ // this buffer onto freeList
+ paBuffer->nextBuffer = paStreamData->freeList;
+ paStreamData->freeList = paBuffer;
+ if (DEBUGGING) {
+ fprintf(stderr, "pa: put on freelist: %p\n", paBuffer);
+ }
+ if (paStreamData->currentBuffer == NULL) {
+ if (DEBUGGING) {
+ fprintf(stderr, "pa: done with last buffer\n");
+ }
+ paStreamData->lastBuffer = NULL;
+ retVal = paComplete;
+ }
+ UNLOCK(paStreamData->lock);
+ if (nBytesToOutput > 0) {
+ if (paStreamData->currentBuffer == NULL) {
+ memset(outputBuffer+offsetInBuffer, 0, nBytesToOutput);
+ } else {
+ paBuffer = paStreamData->currentBuffer;
+ offsetInBuffer = 0;
+ if (DEBUGGING) {
+ fprintf(stderr, "pa: %d more\n", nBytesToOutput);
+ }
+ goto again;
+ }
+ }
+ }
}
return paContinue;
@@ -448,7 +448,7 @@
paStreamData->hasFinished = 1;
if (DEBUGGING) {
- fprintf(stderr, "pa: Stream Completed\n" );
+ fprintf(stderr, "pa: Stream Completed\n" );
}
}
@@ -462,7 +462,7 @@
copyright
"
COPYRIGHT (c) 1993 by Claus Gittinger
- All Rights Reserved
+ All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
@@ -477,9 +477,9 @@
"
Preliminary (unfinished) interface to an audio device.
Currently works with
- LINUXs
- SUNs /dev/audio driver
- IRIX (indy).
+ LINUXs
+ SUNs /dev/audio driver
+ IRIX (indy).
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.
@@ -488,7 +488,7 @@
may change in the future.
[author:]
- Claus Gittinger
+ Claus Gittinger
"
! !
@@ -502,9 +502,9 @@
initialize
UnsupportedOperationSignal isNil ifTrue:[
- UnsupportedOperationSignal := StreamError newSignalMayProceed:true.
- UnsupportedOperationSignal nameClass:self message:#unsupportedOperationSignal.
- UnsupportedOperationSignal notifierString:'unsupported operation'.
+ UnsupportedOperationSignal := StreamError newSignalMayProceed:true.
+ UnsupportedOperationSignal nameClass:self message:#unsupportedOperationSignal.
+ UnsupportedOperationSignal notifierString:'unsupported operation'.
]
! !
@@ -512,24 +512,24 @@
determineConcreteClass
self allSubclassesDo:[:each |
- each isAbstract ifFalse:[
- each isSupported ifTrue:[
- ^ each
- ]
- ]
+ each isAbstract ifFalse:[
+ each isSupported ifTrue:[
+ ^ each
+ ]
+ ]
].
^ nil
!
new
self == SoundStream ifTrue:[
- ConcreteClass isNil ifTrue:[
- ConcreteClass := self determineConcreteClass.
- ConcreteClass isNil ifTrue:[
- self openErrorSignal raiseErrorString:'missing sound support'.
- ].
- ].
- ^ ConcreteClass new.
+ ConcreteClass isNil ifTrue:[
+ ConcreteClass := self determineConcreteClass.
+ ConcreteClass isNil ifTrue:[
+ self openErrorSignal raiseErrorString:'missing sound support'.
+ ].
+ ].
+ ^ ConcreteClass new.
].
^ self basicNew initialize
@@ -605,7 +605,7 @@
|newStream|
OperatingSystem getOSType ~= 'irix' ifTrue:[
- self error:'unsupported audio mode'.
+ self error:'unsupported audio mode'.
].
newStream := self new.
newStream bitsPerSample:16.
@@ -622,7 +622,7 @@
|newStream|
OperatingSystem getOSType ~= 'osx' ifTrue:[
- self error:'unsupported audio mode'.
+ self error:'unsupported audio mode'.
].
newStream := self new.
newStream setAudioFormat:#F32.
@@ -637,7 +637,7 @@
|newStream|
OperatingSystem getOSType ~= 'osx' ifTrue:[
- self error:'unsupported audio mode'.
+ self error:'unsupported audio mode'.
].
newStream := self new.
newStream setAudioFormat:#F32.
@@ -677,19 +677,19 @@
iexp := ix rightShift: 4. "/ extract exponent
mant := ix bitAnd:16r000F. "/ now get mantissa
(iexp > 0) ifTrue:[
- mant := mant + 16. "/ add leading '1', if exponent > 0
+ mant := mant + 16. "/ add leading '1', if exponent > 0
].
mant := (mant bitShift: 4) + 16r0008. "/ now mantissa left justified and
- "/ 1/2 quantization step added
+ "/ 1/2 quantization step added
(iexp > 1) ifTrue:[ "/ now left shift according exponent
- mant := mant bitShift: (iexp - 1).
+ mant := mant bitShift: (iexp - 1).
].
"/ from 12 to 16bit
mant := mant bitShift:4.
aLawValue > 127 ifTrue:[ "/ invert, if negative sample
- ^ mant
+ ^ mant
] ifFalse:[
- ^ mant negated
+ ^ mant negated
].
"
@@ -713,44 +713,44 @@
* made it a primitive.
*/
if (__isSmallInteger(a16bitSignedValue)) {
- int __sign = 0;
- int __absVal = __intVal(a16bitSignedValue);
- int __exp, __mantissa, __byte;
- static char __uLawExp[] =
- {
- 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,
- 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
- 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
- 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
- };
-
- if (__absVal < 0) {
- if (__absVal <= -32256) {
- RETURN (__MKSMALLINT(0));
- }
- __absVal = -__absVal;
- __sign = 0x80;
- } else {
- if (__absVal >= 32256) {
- RETURN (__MKSMALLINT(128));
- }
- }
-
- __exp = __uLawExp[__absVal >> 8];
- __mantissa = (__absVal >> (__exp+3)) & 0xF;
- __byte = ~(__sign | (__exp<<4) | __mantissa) & 0xFF;
- RETURN (__MKSMALLINT(__byte));
+ int __sign = 0;
+ int __absVal = __intVal(a16bitSignedValue);
+ int __exp, __mantissa, __byte;
+ static char __uLawExp[] =
+ {
+ 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,
+ 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
+ 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
+ 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
+ };
+
+ if (__absVal < 0) {
+ if (__absVal <= -32256) {
+ RETURN (__MKSMALLINT(0));
+ }
+ __absVal = -__absVal;
+ __sign = 0x80;
+ } else {
+ if (__absVal >= 32256) {
+ RETURN (__MKSMALLINT(128));
+ }
+ }
+
+ __exp = __uLawExp[__absVal >> 8];
+ __mantissa = (__absVal >> (__exp+3)) & 0xF;
+ __byte = ~(__sign | (__exp<<4) | __mantissa) & 0xFF;
+ RETURN (__MKSMALLINT(__byte));
}
%}.
"/
"/ fallback for non-integral argument
"/
a16bitSignedValue isInteger ifFalse:[
- ^ self uLawToLinear16:a16bitSignedValue asInteger
+ ^ self uLawToLinear16:a16bitSignedValue asInteger
].
^ 0
@@ -774,262 +774,262 @@
Currently unused - but will be"
^ #(
- "0 " -32256
- "1 " -31228
- "2 " -30200
- "3 " -29172
- "4 " -28143
- "5 " -27115
- "6 " -26087
- "7 " -25059
- "8 " -24031
- "9 " -23002
- "10 " -21974
- "11 " -20946
- "12 " -19918
- "13 " -18889
- "14 " -17861
- "15 " -16833
- "16 " -16062
- "17 " -15548
- "18 " -15033
- "19 " -14519
- "20 " -14005
- "21 " -13491
- "22 " -12977
- "23 " -12463
- "24 " -11949
- "25 " -11435
- "26 " -10920
- "27 " -10406
- "28 " -9892
- "29 " -9378
- "30 " -8864
- "31 " -8350
- "32 " -7964
- "33 " -7707
- "34 " -7450
- "35 " -7193
- "36 " -6936
- "37 " -6679
- "38 " -6422
- "39 " -6165
- "40 " -5908
- "41 " -5651
- "42 " -5394
- "43 " -5137
- "44 " -4880
- "45 " -4623
- "46 " -4365
- "47 " -4108
- "48 " -3916
- "49 " -3787
- "50 " -3659
- "51 " -3530
- "52 " -3402
- "53 " -3273
- "54 " -3144
- "55 " -3016
- "56 " -2887
- "57 " -2759
- "58 " -2630
- "59 " -2502
- "60 " -2373
- "61 " -2245
- "62 " -2116
- "63 " -1988
- "64 " -1891
- "65 " -1827
- "66 " -1763
- "67 " -1698
- "68 " -1634
- "69 " -1570
- "70 " -1506
- "71 " -1441
- "72 " -1377
- "73 " -1313
- "74 " -1249
- "75 " -1184
- "76 " -1120
- "77 " -1056
- "78 " -992
- "79 " -927
- "80 " -879
- "81 " -847
- "82 " -815
- "83 " -783
- "84 " -751
- "85 " -718
- "86 " -686
- "87 " -654
- "88 " -622
- "89 " -590
- "90 " -558
- "91 " -526
- "92 " -494
- "93 " -461
- "94 " -429
- "95 " -397
- "96 " -373
- "97 " -357
- "98 " -341
- "99 " -325
- "100" -309
- "101" -293
- "102" -277
- "103" -261
- "104" -245
- "105" -228
- "106" -212
- "107" -196
- "108" -180
- "109" -164
- "110" -148
- "111" -132
- "112" -120
- "113" -112
- "114" -104
- "115" -96
- "116" -88
- "117" -80
- "118" -72
- "119" -64
- "120" -56
- "121" -48
- "122" -40
- "123" -32
- "124" -24
- "125" -16
- "126" -8
- "127" 0
- "128" 32256
- "129" 31228
- "130" 30200
- "131" 29172
- "132" 28143
- "133" 27115
- "134" 26087
- "135" 25059
- "136" 24031
- "137" 23002
- "138" 21974
- "139" 20946
- "140" 19918
- "141" 18889
- "142" 17861
- "143" 16833
- "144" 16062
- "145" 15548
- "146" 15033
- "147" 14519
- "148" 14005
- "149" 13491
- "150" 12977
- "151" 12463
- "152" 11949
- "153" 11435
- "154" 10920
- "155" 10406
- "156" 9892
- "157" 9378
- "158" 8864
- "159" 8350
- "160" 7964
- "161" 7707
- "162" 7450
- "163" 7193
- "164" 6936
- "165" 6679
- "166" 6422
- "167" 6165
- "168" 5908
- "169" 5651
- "170" 5394
- "171" 5137
- "172" 4880
- "173" 4623
- "174" 4365
- "175" 4108
- "176" 3916
- "177" 3787
- "178" 3659
- "179" 3530
- "180" 3402
- "181" 3273
- "182" 3144
- "183" 3016
- "184" 2887
- "185" 2759
- "186" 2630
- "187" 2502
- "188" 2373
- "189" 2245
- "190" 2116
- "191" 1988
- "192" 1891
- "193" 1827
- "194" 1763
- "195" 1698
- "196" 1634
- "197" 1570
- "198" 1506
- "199" 1441
- "200" 1377
- "201" 1313
- "202" 1249
- "203" 1184
- "204" 1120
- "205" 1056
- "206" 992
- "207" 927
- "208" 879
- "209" 847
- "210" 815
- "211" 783
- "212" 751
- "213" 718
- "214" 686
- "215" 654
- "216" 622
- "217" 590
- "218" 558
- "219" 526
- "220" 494
- "221" 461
- "222" 429
- "223" 397
- "224" 373
- "225" 357
- "226" 341
- "227" 325
- "228" 309
- "229" 293
- "230" 277
- "231" 261
- "232" 245
- "233" 228
- "234" 212
- "235" 196
- "236" 180
- "237" 164
- "238" 148
- "239" 132
- "240" 120
- "241" 112
- "242" 104
- "243" 96
- "244" 88
- "245" 80
- "246" 72
- "247" 64
- "248" 56
- "249" 48
- "250" 40
- "251" 32
- "252" 24
- "253" 16
- "254" 8
- "255" 0
+ "0 " -32256
+ "1 " -31228
+ "2 " -30200
+ "3 " -29172
+ "4 " -28143
+ "5 " -27115
+ "6 " -26087
+ "7 " -25059
+ "8 " -24031
+ "9 " -23002
+ "10 " -21974
+ "11 " -20946
+ "12 " -19918
+ "13 " -18889
+ "14 " -17861
+ "15 " -16833
+ "16 " -16062
+ "17 " -15548
+ "18 " -15033
+ "19 " -14519
+ "20 " -14005
+ "21 " -13491
+ "22 " -12977
+ "23 " -12463
+ "24 " -11949
+ "25 " -11435
+ "26 " -10920
+ "27 " -10406
+ "28 " -9892
+ "29 " -9378
+ "30 " -8864
+ "31 " -8350
+ "32 " -7964
+ "33 " -7707
+ "34 " -7450
+ "35 " -7193
+ "36 " -6936
+ "37 " -6679
+ "38 " -6422
+ "39 " -6165
+ "40 " -5908
+ "41 " -5651
+ "42 " -5394
+ "43 " -5137
+ "44 " -4880
+ "45 " -4623
+ "46 " -4365
+ "47 " -4108
+ "48 " -3916
+ "49 " -3787
+ "50 " -3659
+ "51 " -3530
+ "52 " -3402
+ "53 " -3273
+ "54 " -3144
+ "55 " -3016
+ "56 " -2887
+ "57 " -2759
+ "58 " -2630
+ "59 " -2502
+ "60 " -2373
+ "61 " -2245
+ "62 " -2116
+ "63 " -1988
+ "64 " -1891
+ "65 " -1827
+ "66 " -1763
+ "67 " -1698
+ "68 " -1634
+ "69 " -1570
+ "70 " -1506
+ "71 " -1441
+ "72 " -1377
+ "73 " -1313
+ "74 " -1249
+ "75 " -1184
+ "76 " -1120
+ "77 " -1056
+ "78 " -992
+ "79 " -927
+ "80 " -879
+ "81 " -847
+ "82 " -815
+ "83 " -783
+ "84 " -751
+ "85 " -718
+ "86 " -686
+ "87 " -654
+ "88 " -622
+ "89 " -590
+ "90 " -558
+ "91 " -526
+ "92 " -494
+ "93 " -461
+ "94 " -429
+ "95 " -397
+ "96 " -373
+ "97 " -357
+ "98 " -341
+ "99 " -325
+ "100" -309
+ "101" -293
+ "102" -277
+ "103" -261
+ "104" -245
+ "105" -228
+ "106" -212
+ "107" -196
+ "108" -180
+ "109" -164
+ "110" -148
+ "111" -132
+ "112" -120
+ "113" -112
+ "114" -104
+ "115" -96
+ "116" -88
+ "117" -80
+ "118" -72
+ "119" -64
+ "120" -56
+ "121" -48
+ "122" -40
+ "123" -32
+ "124" -24
+ "125" -16
+ "126" -8
+ "127" 0
+ "128" 32256
+ "129" 31228
+ "130" 30200
+ "131" 29172
+ "132" 28143
+ "133" 27115
+ "134" 26087
+ "135" 25059
+ "136" 24031
+ "137" 23002
+ "138" 21974
+ "139" 20946
+ "140" 19918
+ "141" 18889
+ "142" 17861
+ "143" 16833
+ "144" 16062
+ "145" 15548
+ "146" 15033
+ "147" 14519
+ "148" 14005
+ "149" 13491
+ "150" 12977
+ "151" 12463
+ "152" 11949
+ "153" 11435
+ "154" 10920
+ "155" 10406
+ "156" 9892
+ "157" 9378
+ "158" 8864
+ "159" 8350
+ "160" 7964
+ "161" 7707
+ "162" 7450
+ "163" 7193
+ "164" 6936
+ "165" 6679
+ "166" 6422
+ "167" 6165
+ "168" 5908
+ "169" 5651
+ "170" 5394
+ "171" 5137
+ "172" 4880
+ "173" 4623
+ "174" 4365
+ "175" 4108
+ "176" 3916
+ "177" 3787
+ "178" 3659
+ "179" 3530
+ "180" 3402
+ "181" 3273
+ "182" 3144
+ "183" 3016
+ "184" 2887
+ "185" 2759
+ "186" 2630
+ "187" 2502
+ "188" 2373
+ "189" 2245
+ "190" 2116
+ "191" 1988
+ "192" 1891
+ "193" 1827
+ "194" 1763
+ "195" 1698
+ "196" 1634
+ "197" 1570
+ "198" 1506
+ "199" 1441
+ "200" 1377
+ "201" 1313
+ "202" 1249
+ "203" 1184
+ "204" 1120
+ "205" 1056
+ "206" 992
+ "207" 927
+ "208" 879
+ "209" 847
+ "210" 815
+ "211" 783
+ "212" 751
+ "213" 718
+ "214" 686
+ "215" 654
+ "216" 622
+ "217" 590
+ "218" 558
+ "219" 526
+ "220" 494
+ "221" 461
+ "222" 429
+ "223" 397
+ "224" 373
+ "225" 357
+ "226" 341
+ "227" 325
+ "228" 309
+ "229" 293
+ "230" 277
+ "231" 261
+ "232" 245
+ "233" 228
+ "234" 212
+ "235" 196
+ "236" 180
+ "237" 164
+ "238" 148
+ "239" 132
+ "240" 120
+ "241" 112
+ "242" 104
+ "243" 96
+ "244" 88
+ "245" 80
+ "246" 72
+ "247" 64
+ "248" 56
+ "249" 48
+ "250" 40
+ "251" 32
+ "252" 24
+ "253" 16
+ "254" 8
+ "255" 0
) at:(uLawValue + 1)
"Modified: / 9.12.1997 / 16:34:17 / cg"
@@ -1039,10 +1039,10 @@
defaultAudioFormat
OperatingSystem isMSWINDOWSlike ifTrue:[
- ^ #S16
+ ^ #S16
].
OperatingSystem isOSXlike ifTrue:[
- ^ #S16
+ ^ #S16
].
^ #U8
!
@@ -1051,10 +1051,10 @@
"minimum, supported by all audio systems"
OperatingSystem isMSWINDOWSlike ifTrue:[
- ^ 16
+ ^ 16
].
OperatingSystem isOSXlike ifTrue:[
- ^ 16
+ ^ 16
].
^ 8
!
@@ -1080,7 +1080,7 @@
mime := aFilename asFilename mimeTypeFromName.
mime isAudioType ifFalse:[
- self error:'not an audio file: ',aFilename asFilename baseName
+ self error:'not an audio file: ',aFilename asFilename baseName
].
self halt.
inStream := aFilename asFilename readStream.
@@ -1094,8 +1094,8 @@
buffer := ByteArray new:4096.
[(count := inStream nextBytesInto:buffer) > 0] whileTrue:[
- totalCount := totalCount + count.
- soundStream nextPutBytes:count from:buffer.
+ totalCount := totalCount + count.
+ soundStream nextPutBytes:count from:buffer.
].
inStream close.
@@ -1156,7 +1156,7 @@
"return a message string describing the last error"
lastErrorString notNil ifTrue:[
- ^ lastErrorString
+ ^ lastErrorString
].
^ super lastErrorString
! !
@@ -1177,43 +1177,43 @@
ok := false.
supported := self supportedAudioFormats.
aNumber == 16 ifTrue:[
- #(S16 S16_LE S16_BE U16 U16_LE U16_BE) doWithExit:[:fmt :exit |
- (supported includes:fmt) ifTrue:[
- self setAudioFormat:fmt.
- ok := true.
- exit value:nil.
- ]
- ]
+ #(S16 S16_LE S16_BE U16 U16_LE U16_BE) doWithExit:[:fmt :exit |
+ (supported includes:fmt) ifTrue:[
+ self setAudioFormat:fmt.
+ ok := true.
+ exit value:nil.
+ ]
+ ]
].
aNumber == 8 ifTrue:[
- #(S8 U8) doWithExit:[:fmt :exit |
- (supported includes:fmt) ifTrue:[
- self setAudioFormat:fmt.
- ok := true.
- exit value:nil.
- ]
- ]
+ #(S8 U8) doWithExit:[:fmt :exit |
+ (supported includes:fmt) ifTrue:[
+ self setAudioFormat:fmt.
+ ok := true.
+ exit value:nil.
+ ]
+ ]
].
aNumber == 24 ifTrue:[
- #(S24 S24_LE S24_BE U24 U24_LE U24_BE) doWithExit:[:fmt :exit |
- (supported includes:fmt) ifTrue:[
- self setAudioFormat:fmt.
- ok := true.
- exit value:nil.
- ]
- ]
+ #(S24 S24_LE S24_BE U24 U24_LE U24_BE) doWithExit:[:fmt :exit |
+ (supported includes:fmt) ifTrue:[
+ self setAudioFormat:fmt.
+ ok := true.
+ exit value:nil.
+ ]
+ ]
].
aNumber == 32 ifTrue:[
- #(S32 S32_LE S32_BE U32 U32_LE U32_BE) doWithExit:[:fmt :exit |
- (supported includes:fmt) ifTrue:[
- self setAudioFormat:fmt.
- ok := true.
- exit value:nil.
- ]
- ]
+ #(S32 S32_LE S32_BE U32 U32_LE U32_BE) doWithExit:[:fmt :exit |
+ (supported includes:fmt) ifTrue:[
+ self setAudioFormat:fmt.
+ ok := true.
+ exit value:nil.
+ ]
+ ]
].
ok ifFalse:[
- UnsupportedOperationSignal raiseRequestErrorString:'unsupported format'.
+ UnsupportedOperationSignal raiseRequestErrorString:'unsupported format'.
].
bitsPerSample := aNumber
!
@@ -1250,18 +1250,18 @@
"debugging interface - dump the current settings"
audioFormat == #S16 ifTrue:[
- UninterpretedBytes isBigEndian ifTrue:[
- audioFormat := #S16_BE
- ] ifFalse:[
- audioFormat := #S16_LE
- ]
+ UninterpretedBytes isBigEndian ifTrue:[
+ audioFormat := #S16_BE
+ ] ifFalse:[
+ audioFormat := #S16_LE
+ ]
].
audioFormat == #U16 ifTrue:[
- UninterpretedBytes isBigEndian ifTrue:[
- audioFormat := #U16_BE
- ] ifFalse:[
- audioFormat := #U16_LE
- ]
+ UninterpretedBytes isBigEndian ifTrue:[
+ audioFormat := #U16_BE
+ ] ifFalse:[
+ audioFormat := #U16_LE
+ ]
].
Transcript show:'sampleRate: '; showCR:sampleRate.
Transcript show:'format: '; showCR:audioFormat.
@@ -1276,7 +1276,7 @@
fileDescriptorOrNil
handle notNil ifTrue:[
- ^ self fileDescriptor.
+ ^ self fileDescriptor.
].
^ nil
!
@@ -1312,24 +1312,24 @@
audioFormat := aSymbol.
((audioFormat == #U8) or:[audioFormat == #S8]) ifTrue:[
- bitsPerSample := 8.
- ^ self
+ bitsPerSample := 8.
+ ^ self
].
(#(U16 U16_LE U16_BE S16 S16_LE S16_BE) includes:audioFormat) ifTrue:[
- bitsPerSample := 16.
- ^ self
+ bitsPerSample := 16.
+ ^ self
].
(#(U24 U24_LE U24_BE S24 S24_LE S24_BE) includes:audioFormat) ifTrue:[
- bitsPerSample := 24.
- ^ self
+ bitsPerSample := 24.
+ ^ self
].
(#(U32 U32_LE U32_BE S32 S32_LE S32_BE) includes:audioFormat) ifTrue:[
- bitsPerSample := 32.
- ^ self
+ bitsPerSample := 32.
+ ^ self
].
(audioFormat == #F32) ifTrue:[
- bitsPerSample := 32.
- ^ self
+ bitsPerSample := 32.
+ ^ self
].
bitsPerSample := 8.
@@ -1375,25 +1375,25 @@
supportedAudioFormats
"return a collection of supported audio formats.
possibly returned symbols are:
- U8 unsigned 8bit samples
- S8 signed 8bit samples
- U16 unsigned 16bit samples in native format
- U16_LE unsigned 16bit big endian samples
- U16_BE unsigned 16bit big endian samples
- S16 signed 16bit little endian samples in native format
- S16_LE signed 16bit little endian samples
- S16_BE signed 16bit big endian samples
- S24 signed 24bit little endian samples in native format
- S24_LE signed 24bit little endian samples
- S24_BE signed 24bit big endian samples
- S32 signed 32bit little endian samples in native format
- S32_LE signed 32bit little endian samples
- S32_BE signed 32bit big endian samples
- F32 float samples
- MPEG audio mpeg encoded
- MU_LAW u-law encoded 8bit samples
- A_LAW a-law encoded 8bit samples
- IMA_ADPCM adpcm encoded
+ U8 unsigned 8bit samples
+ S8 signed 8bit samples
+ U16 unsigned 16bit samples in native format
+ U16_LE unsigned 16bit big endian samples
+ U16_BE unsigned 16bit big endian samples
+ S16 signed 16bit little endian samples in native format
+ S16_LE signed 16bit little endian samples
+ S16_BE signed 16bit big endian samples
+ S24 signed 24bit little endian samples in native format
+ S24_LE signed 24bit little endian samples
+ S24_BE signed 24bit big endian samples
+ S32 signed 32bit little endian samples in native format
+ S32_LE signed 32bit little endian samples
+ S32_BE signed 32bit big endian samples
+ F32 float samples
+ MPEG audio mpeg encoded
+ MU_LAW u-law encoded 8bit samples
+ A_LAW a-law encoded 8bit samples
+ IMA_ADPCM adpcm encoded
the set of returned symbols depends on the underlying sound hardware.
"
@@ -1435,7 +1435,7 @@
isOpen
self isExecutor ifTrue:[
- ^ false.
+ ^ false.
].
handle1 notNil ifTrue:[^ true].
handle2 notNil ifTrue:[^ true].
@@ -1474,10 +1474,10 @@
|buffer numSamples val scale isUnsigned restSamples|
(audioFormat startsWith:#U16) ifFalse:[
- (audioFormat startsWith:#S16) ifFalse:[
- self error:'must be in 16bit mode' mayProceed:true.
- ^ self
- ]
+ (audioFormat startsWith:#S16) ifFalse:[
+ self error:'must be in 16bit mode' mayProceed:true.
+ ^ self
+ ]
].
numSamples := self sampleRate.
@@ -1489,20 +1489,20 @@
scale := freq * 2 * (Float pi).
1 to:numSamples do:[:i |
- val := (scale * i / self sampleRate) sin.
- val := (val * 16r7FFF) rounded.
- isUnsigned ifTrue:[
- val := val + 32768
- ].
- buffer at:i put:(val bitAnd:16rFFFF)
+ val := (scale * i / self sampleRate) sin.
+ val := (val * 16r7FFF) rounded.
+ isUnsigned ifTrue:[
+ val := val + 32768
+ ].
+ buffer at:i put:(val bitAnd:16rFFFF)
].
1 to:nSeconds truncated do:[:s |
- self nextPutBytes:(numSamples*2) from:buffer startingAt:1
+ self nextPutBytes:(numSamples*2) from:buffer startingAt:1
].
restSamples := ((nSeconds - nSeconds truncated) * numSamples) truncated.
restSamples > 0 ifTrue:[
- self nextPutBytes:(restSamples*2) from:buffer startingAt:1
+ self nextPutBytes:(restSamples*2) from:buffer startingAt:1
].
"
@@ -1523,8 +1523,8 @@
"output some tone for some time - a test method"
audioFormat == #F32 ifTrue:[
- self playSineF32:freq forSeconds:nSeconds.
- ^ self.
+ self playSineF32:freq forSeconds:nSeconds.
+ ^ self.
].
self playSine16:freq forSeconds:nSeconds.
@@ -1543,7 +1543,7 @@
|buffer numSamples val scale restSamples numChannels|
(audioFormat == #F32) ifFalse:[
- self error:'must be in float mode' mayProceed:true.
+ self error:'must be in float mode' mayProceed:true.
].
numSamples := self sampleRate.
@@ -1554,24 +1554,24 @@
scale := freq * 2 * (Float pi).
numChannels == 2 ifTrue:[
- 1 to:numSamples do:[:i |
- val := (scale * i / self sampleRate) sin.
- buffer at:(i-1)*2 put:val.
- buffer at:(i-1)*2+1 put:0.
- ].
+ 1 to:numSamples do:[:i |
+ val := (scale * i / self sampleRate) sin.
+ buffer at:(i-1)*2 put:val.
+ buffer at:(i-1)*2+1 put:0.
+ ].
] ifFalse:[
- 1 to:numSamples do:[:i |
- val := (scale * i / self sampleRate) sin.
- buffer at:i put:val
- ].
+ 1 to:numSamples do:[:i |
+ val := (scale * i / self sampleRate) sin.
+ buffer at:i put:val
+ ].
].
1 to:nSeconds truncated do:[:s |
- self nextPutBytes:(numSamples*4) from:buffer startingAt:1
+ self nextPutBytes:(numSamples*4) from:buffer startingAt:1
].
restSamples := ((nSeconds - nSeconds truncated) * numSamples) truncated.
restSamples > 0 ifTrue:[
- self nextPutBytes:(restSamples*4) from:buffer startingAt:1
+ self nextPutBytes:(restSamples*4) from:buffer startingAt:1
].
"
@@ -1586,11 +1586,11 @@
testMelody
3 timesRepeat:[
- self playSine:220 forSeconds:0.5.
- self playSine:440 forSeconds:0.5.
- self playSine:880 forSeconds:0.5.
- self playSine:1760 forSeconds:0.5.
- self playSine:3520 forSeconds:0.5.
+ self playSine:220 forSeconds:0.5.
+ self playSine:440 forSeconds:0.5.
+ self playSine:880 forSeconds:0.5.
+ self playSine:1760 forSeconds:0.5.
+ self playSine:3520 forSeconds:0.5.
]
"
@@ -1650,7 +1650,7 @@
].
buffer at:i put:(val bitAnd:16rFFFF)
].
-self halt.
+
1 to:nSeconds truncated do:[:s |
self nextPutBytes:(numSamples*2) from:buffer startingAt:1
].
@@ -1934,25 +1934,25 @@
documentation to be added.
class:
- <a short class summary here, describing what instances represent>
+ <a short class summary here, describing what instances represent>
responsibilities:
- <describing what my main role is>
+ <describing what my main role is>
collaborators:
- <describing with whom and how I talk to>
+ <describing with whom and how I talk to>
API:
- <public api and main messages>
+ <public api and main messages>
example:
- <a one-line examples on how to use - can also be in a separate example method>
+ <a one-line examples on how to use - can also be in a separate example method>
implementation:
- <implementation points>
+ <implementation points>
[author:]
- exept MBP
+ exept MBP
[instance variables:]
@@ -1984,118 +1984,118 @@
fd := self fileDescriptorOrNil.
audioFormat == #S16 ifTrue:[
- UninterpretedBytes isBigEndian ifTrue:[
- audioFormat := #S16_BE
- ] ifFalse:[
- audioFormat := #S16_LE
- ]
+ UninterpretedBytes isBigEndian ifTrue:[
+ audioFormat := #S16_BE
+ ] ifFalse:[
+ audioFormat := #S16_LE
+ ]
].
audioFormat == #U16 ifTrue:[
- UninterpretedBytes isBigEndian ifTrue:[
- audioFormat := #U16_BE
- ] ifFalse:[
- audioFormat := #U16_LE
- ]
+ UninterpretedBytes isBigEndian ifTrue:[
+ audioFormat := #U16_BE
+ ] ifFalse:[
+ audioFormat := #U16_LE
+ ]
].
%{
#ifdef SUPPORT_DEV_AUDIO
if (fd != nil) {
- int f = __intVal(fd);
- int __blockSize = -1;
- int __speed = -1;
- int __channels = __intVal(__INST(numberOfChannels));
- int __stereo = __channels > 1;
- int __format = -1;
-
- channels = nil;
- blockSize = nil;
- stereo = nil;
- speed = nil;
+ int f = __intVal(fd);
+ int __blockSize = -1;
+ int __speed = -1;
+ int __channels = __intVal(__INST(numberOfChannels));
+ int __stereo = __channels > 1;
+ int __format = -1;
+
+ channels = nil;
+ blockSize = nil;
+ stereo = nil;
+ speed = nil;
# if defined(SNDCTL_DSP_GETBLKSIZE)
- if (ioctl(f, SNDCTL_DSP_GETBLKSIZE, &__blockSize) >= 0) {
- blockSize = __MKSMALLINT(__blockSize);
- }
+ if (ioctl(f, SNDCTL_DSP_GETBLKSIZE, &__blockSize) >= 0) {
+ blockSize = __MKSMALLINT(__blockSize);
+ }
# endif
# if defined(SNDCTL_DSP_CHANNELS)
- if (ioctl(f, SNDCTL_DSP_CHANNELS, &__channels) >= 0) {
- channels = __MKSMALLINT(__channels);
- stereo = __MKSMALLINT(__channels > 1);
- }
+ if (ioctl(f, SNDCTL_DSP_CHANNELS, &__channels) >= 0) {
+ channels = __MKSMALLINT(__channels);
+ stereo = __MKSMALLINT(__channels > 1);
+ }
# else
# if defined(SNDCTL_DSP_STEREO)
- if (ioctl(f, SNDCTL_DSP_STEREO, &__stereo) >= 0) {
- stereo = __MKSMALLINT(__stereo);
- }
+ if (ioctl(f, SNDCTL_DSP_STEREO, &__stereo) >= 0) {
+ stereo = __MKSMALLINT(__stereo);
+ }
# endif
# endif
# if defined(SNDCTL_DSP_SPEED)
- if (ioctl(f, SNDCTL_DSP_SPEED, &__speed) >= 0) {
- speed = __MKSMALLINT(__speed);
- }
+ if (ioctl(f, SNDCTL_DSP_SPEED, &__speed) >= 0) {
+ speed = __MKSMALLINT(__speed);
+ }
# endif
# if defined(SNDCTL_DSP_GETFMT)
- if (ioctl(f, SNDCTL_DSP_GETFMT, &__format) >= 0) {
- format = __MKSMALLINT(__format);
- }
+ if (ioctl(f, SNDCTL_DSP_GETFMT, &__format) >= 0) {
+ format = __MKSMALLINT(__format);
+ }
# else
# if defined(SNDCTL_DSP_SETFMT) && defined(AFMT_QUERY)
- __format = AFMT_QUERY;
- if (ioctl(f, SNDCTL_DSP_SETFMT, &__format) >= 0) {
- switch (__format) {
+ __format = AFMT_QUERY;
+ if (ioctl(f, SNDCTL_DSP_SETFMT, &__format) >= 0) {
+ switch (__format) {
# ifdef AFMT_MU_LAW
- case AFMT_MU_LAW:
- format = @symbol(MU_LAW);
- break;
+ case AFMT_MU_LAW:
+ format = @symbol(MU_LAW);
+ break;
# endif
# ifdef AFMT_A_LAW
- case AFMT_A_LAW:
- format = @symbol(A_LAW);
- break;
+ case AFMT_A_LAW:
+ format = @symbol(A_LAW);
+ break;
# endif
# ifdef AFMT_U8
- case AFMT_U8:
- format = @symbol(U8);
- break;
+ case AFMT_U8:
+ format = @symbol(U8);
+ break;
# endif
# ifdef AFMT_S8
- case AFMT_S8:
- format = @symbol(S8);
- break;
+ case AFMT_S8:
+ format = @symbol(S8);
+ break;
# endif
# ifdef AFMT_S16_LE
- case AFMT_S16_LE:
- format = @symbol(S16_LE);
- break;
+ case AFMT_S16_LE:
+ format = @symbol(S16_LE);
+ break;
# endif
# ifdef AFMT_S16_BE
- case AFMT_S16_BE:
- format = @symbol(S16_BE);
- break;
+ case AFMT_S16_BE:
+ format = @symbol(S16_BE);
+ break;
# endif
# ifdef AFMT_U16_LE
- case AFMT_U16_LE:
- format = @symbol(U16_LE);
- break;
+ case AFMT_U16_LE:
+ format = @symbol(U16_LE);
+ break;
# endif
# ifdef AFMT_U16_BE
- case AFMT_U16_BE:
- format = @symbol(U16_BE);
- break;
+ case AFMT_U16_BE:
+ format = @symbol(U16_BE);
+ break;
# endif
# ifdef AFMT_MPEG
- case AFMT_MPEG:
- format = @symbol(MPEG);
- break;
+ case AFMT_MPEG:
+ format = @symbol(MPEG);
+ break;
# endif
- default:
- format = nil;
- }
- }
+ default:
+ format = nil;
+ }
+ }
}
# endif
# endif
@@ -2103,19 +2103,19 @@
%}.
format notNil ifTrue:[
- Transcript show:'format: '; showCR:format
+ Transcript show:'format: '; showCR:format
].
blockSize notNil ifTrue:[
- Transcript show:'blockSize: '; showCR:blockSize
+ Transcript show:'blockSize: '; showCR:blockSize
].
speed notNil ifTrue:[
- Transcript show:'speed: '; showCR:speed
+ Transcript show:'speed: '; showCR:speed
].
channels notNil ifTrue:[
- Transcript show:'channels: '; showCR:channels
+ Transcript show:'channels: '; showCR:channels
].
stereo notNil ifTrue:[
- Transcript show:'stereo: '; showCR:stereo
+ Transcript show:'stereo: '; showCR:stereo
].
Transcript show:'supported audioFormats: '; showCR:(self supportedAudioFormats).
@@ -2144,21 +2144,21 @@
FILE *f;
if ((fp = __INST(handle)) != nil) {
- f = __FILEVal(fp);
- __INST(handle) = nil;
+ f = __FILEVal(fp);
+ __INST(handle) = nil;
# ifdef LINUX
- sigsetmask(~0);
+ sigsetmask(~0);
# endif
- if (__INST(buffered) == true) {
- fflush(f);
- fclose(f);
- } else {
- fd = fileno(f);
- close(fd);
- fclose(f);
- }
+ if (__INST(buffered) == true) {
+ fflush(f);
+ fclose(f);
+ } else {
+ fd = fileno(f);
+ close(fd);
+ fclose(f);
+ }
# ifdef LINUX
- sigsetmask(0);
+ sigsetmask(0);
# endif
}
RETURN (self);
@@ -2177,60 +2177,60 @@
ok = false;
if (strcmp(__stringVal(aMode), "w") == 0) {
- __mode = O_WRONLY;
+ __mode = O_WRONLY;
} else if (strcmp(__stringVal(aMode), "r") == 0) {
- __mode = O_RDONLY;
+ __mode = O_RDONLY;
} else {
- __mode = O_RDWR;
+ __mode = O_RDWR;
}
do {
- __BEGIN_INTERRUPTABLE__
- __fd = open((char *) __stringVal(__INST(pathName)), __mode /* |O_NDELAY */);
- __END_INTERRUPTABLE__
+ __BEGIN_INTERRUPTABLE__
+ __fd = open((char *) __stringVal(__INST(pathName)), __mode /* |O_NDELAY */);
+ __END_INTERRUPTABLE__
} while ((__fd < 0) && (errno == EINTR));
if (__fd >= 0) {
- /*
- * make it a FILE *
- */
- f = fdopen(__fd, __stringVal(aMode));
- if (! f) {
- error = __mkSmallInteger(errno);
- __BEGIN_INTERRUPTABLE__
- close(__fd);
- __END_INTERRUPTABLE__
- goto out;
- }
- setbuf(f, NULL);
- __INST(buffered) = false;
- __INST(handle) = __MKEXTERNALADDRESS(f);
- __STORESELF(handle);
+ /*
+ * make it a FILE *
+ */
+ f = fdopen(__fd, __stringVal(aMode));
+ if (! f) {
+ error = __mkSmallInteger(errno);
+ __BEGIN_INTERRUPTABLE__
+ close(__fd);
+ __END_INTERRUPTABLE__
+ goto out;
+ }
+ setbuf(f, NULL);
+ __INST(buffered) = false;
+ __INST(handle) = __MKEXTERNALADDRESS(f);
+ __STORESELF(handle);
#if defined(PCM_ENABLE_OUTPUT) && defined(PCM_ENABLE_INPUT)
# if defined(SNDCTL_DSP_SETTRIGGER)
- if (__mode == O_RDWR) {
- int enable_bits = ~(PCM_ENABLE_OUTPUT|PCM_ENABLE_INPUT);
-
- if (ioctl(__fd, SNDCTL_DSP_SETTRIGGER, &enable_bits) == -1)
- {
- console_fprintf(stderr, "can't request synchronous start of fullduplex operation");
- }
- }
+ if (__mode == O_RDWR) {
+ int enable_bits = ~(PCM_ENABLE_OUTPUT|PCM_ENABLE_INPUT);
+
+ if (ioctl(__fd, SNDCTL_DSP_SETTRIGGER, &enable_bits) == -1)
+ {
+ console_fprintf(stderr, "can't request synchronous start of fullduplex operation");
+ }
+ }
# endif
#endif
- ok = true;
+ ok = true;
} else {
- error = __mkSmallInteger(errno);
+ error = __mkSmallInteger(errno);
}
out:;
#endif /* SUPPORT_DEV_AUDIO */
%}.
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.
! !
@@ -2243,12 +2243,12 @@
super initialize.
OperatingSystem isUNIXlike ifTrue:[
- '/dev/audio' asFilename exists ifTrue:[
- "/
- "/ sunos or linux
- "/
- pathName := '/dev/audio'.
- ].
+ '/dev/audio' asFilename exists ifTrue:[
+ "/
+ "/ sunos or linux
+ "/
+ pathName := '/dev/audio'.
+ ].
].
!
@@ -2259,19 +2259,19 @@
fd := self fileDescriptorOrNil.
fd isNil ifTrue:[
- self errorNotOpen.
- ^ nil
+ self errorNotOpen.
+ ^ nil
].
%{
#ifdef SUPPORT_DEV_AUDIO
int f = __intVal(fd);
if (__isSmallInteger(fd)) {
- int __dummy;
+ int __dummy;
# if defined(SNDCTL_DSP_RESET)
- if (ioctl(f, SNDCTL_DSP_RESET, &__dummy) >= 0) {
- RETURN (self);
- }
+ if (ioctl(f, SNDCTL_DSP_RESET, &__dummy) >= 0) {
+ RETURN (self);
+ }
# endif
}
#endif /* SUPPORT_DEV_AUDIO */
@@ -2294,120 +2294,120 @@
fd := self fileDescriptor.
fd isNil ifTrue:[
- ^ self
+ ^ self
].
%{
#ifdef SUPPORT_DEV_AUDIO
OBJ sym = aSymbol;
if (__isSmallInteger(fd)) {
- int f = __intVal(fd);
- int __fmt = 0, __fmtWant;
- union {
- unsigned short us;
- unsigned char ub[2];
- } u;
-
- if (__isSymbol(sym)) {
- if (sym == @symbol(U16)) {
- u.us = 0x1234;
- if (u.ub[0] == 0x34) {
- /* printf("U16_LE\n"); */
- sym = @symbol(U16_LE);
- } else {
- /* printf("U16_BE\n"); */
- sym = @symbol(U16_BE);
- }
- } else if (sym == @symbol(S16)) {
- u.us = 0x1234;
- if (u.ub[0] == 0x34) {
- /* printf("S16_LE\n"); */
- sym = @symbol(S16_LE);
- } else {
- /* printf("S16_BE\n"); */
- sym = @symbol(S16_BE);
- }
- }
-
- if (0) {
+ int f = __intVal(fd);
+ int __fmt = 0, __fmtWant;
+ union {
+ unsigned short us;
+ unsigned char ub[2];
+ } u;
+
+ if (__isSymbol(sym)) {
+ if (sym == @symbol(U16)) {
+ u.us = 0x1234;
+ if (u.ub[0] == 0x34) {
+ /* printf("U16_LE\n"); */
+ sym = @symbol(U16_LE);
+ } else {
+ /* printf("U16_BE\n"); */
+ sym = @symbol(U16_BE);
+ }
+ } else if (sym == @symbol(S16)) {
+ u.us = 0x1234;
+ if (u.ub[0] == 0x34) {
+ /* printf("S16_LE\n"); */
+ sym = @symbol(S16_LE);
+ } else {
+ /* printf("S16_BE\n"); */
+ sym = @symbol(S16_BE);
+ }
+ }
+
+ if (0) {
# ifdef AFMT_MU_LAW
- } else if (sym == @symbol(MU_LAW)) {
- __fmt = AFMT_MU_LAW;
+ } else if (sym == @symbol(MU_LAW)) {
+ __fmt = AFMT_MU_LAW;
# endif
# ifdef AFMT_A_LAW
- } else if (sym == @symbol(A_LAW)) {
- __fmt = AFMT_A_LAW;
+ } else if (sym == @symbol(A_LAW)) {
+ __fmt = AFMT_A_LAW;
# endif
# ifdef AFMT_IMA_ADPCM
- } else if (sym == @symbol(IMA_ADPCM)) {
- __fmt = AFMT_IMA_ADPCM;
+ } else if (sym == @symbol(IMA_ADPCM)) {
+ __fmt = AFMT_IMA_ADPCM;
# endif
# ifdef AFMT_U8
- } else if (sym == @symbol(U8)) {
- __fmt = AFMT_U8;
+ } else if (sym == @symbol(U8)) {
+ __fmt = AFMT_U8;
# endif
# ifdef AFMT_S8
- } else if (sym == @symbol(S8)) {
- __fmt = AFMT_S8;
+ } else if (sym == @symbol(S8)) {
+ __fmt = AFMT_S8;
# endif
# ifdef AFMT_U16_LE
- } else if (sym == @symbol(U16_LE)) {
- __fmt = AFMT_U16_LE;
+ } else if (sym == @symbol(U16_LE)) {
+ __fmt = AFMT_U16_LE;
# endif
# ifdef AFMT_U16_BE
- } else if (sym == @symbol(U16_BE)) {
- __fmt = AFMT_U16_BE;
+ } else if (sym == @symbol(U16_BE)) {
+ __fmt = AFMT_U16_BE;
# endif
# ifdef AFMT_S16_LE
- } else if (sym == @symbol(S16_LE)) {
- __fmt = AFMT_S16_LE;
+ } else if (sym == @symbol(S16_LE)) {
+ __fmt = AFMT_S16_LE;
# endif
# ifdef AFMT_S16_BE
- } else if (sym == @symbol(S16_BE)) {
- __fmt = AFMT_S16_BE;
+ } else if (sym == @symbol(S16_BE)) {
+ __fmt = AFMT_S16_BE;
# endif
# ifdef AFMT_MPEG
- } else if (sym == @symbol(MPEG)) {
- __fmt = AFMT_MPEG;
+ } else if (sym == @symbol(MPEG)) {
+ __fmt = AFMT_MPEG;
# endif
# ifdef AUDIO_FORMAT_LINEAR16BIT
- } else if (sym == @symbol(S16)) {
- __fmt = AUDIO_FORMAT_LINEAR16BIT;
+ } else if (sym == @symbol(S16)) {
+ __fmt = AUDIO_FORMAT_LINEAR16BIT;
# endif
# ifdef AUDIO_FORMAT_ULAW
- } else if (sym == @symbol(MU_LAW)) {
- __fmt = AUDIO_FORMAT_ULAW;
+ } else if (sym == @symbol(MU_LAW)) {
+ __fmt = AUDIO_FORMAT_ULAW;
# endif
# ifdef AUDIO_FORMAT_ALAW
- } else if (sym == @symbol(A_LAW)) {
- __fmt = AUDIO_FORMAT_ALAW;
+ } else if (sym == @symbol(A_LAW)) {
+ __fmt = AUDIO_FORMAT_ALAW;
# endif
- } else {
- console_fprintf(stderr, "bad format: %s\n", __stringVal(sym));
- ok = false;
- goto bad;
- }
- }
+ } else {
+ console_fprintf(stderr, "bad format: %s\n", __stringVal(sym));
+ ok = false;
+ goto bad;
+ }
+ }
# ifdef SNDCTL_DSP_SETFMT
- __fmtWant = __fmt;
-
- if (ioctl(f, SNDCTL_DSP_SETFMT, &__fmt) >= 0) {
- if (__fmt == __fmtWant) {
- __INST(audioFormat) = sym;
- } else {
- /* console_fprintf(stderr, "want: %x; got: %x\n", __fmtWant, __fmt); */
- }
- } else {
- /* console_fprintf(stderr, "got err-ret from setFmp %x\n", __fmt); */
- ok = false;
- }
+ __fmtWant = __fmt;
+
+ if (ioctl(f, SNDCTL_DSP_SETFMT, &__fmt) >= 0) {
+ if (__fmt == __fmtWant) {
+ __INST(audioFormat) = sym;
+ } else {
+ /* console_fprintf(stderr, "want: %x; got: %x\n", __fmtWant, __fmt); */
+ }
+ } else {
+ /* console_fprintf(stderr, "got err-ret from setFmp %x\n", __fmt); */
+ ok = false;
+ }
# else
# ifdef AUDIO_SET_DATA_FORMAT /* hpux */
- if (ioctl (f, AUDIO_SET_DATA_FORMAT, __fmt)) {
- /* console_fprintf(stderr, "got err-ret from AUDIO_SET_DATA_FORMAT\n"); */
- }
+ if (ioctl (f, AUDIO_SET_DATA_FORMAT, __fmt)) {
+ /* console_fprintf(stderr, "got err-ret from AUDIO_SET_DATA_FORMAT\n"); */
+ }
# endif
# endif /* SNDCTL_DSP_SETFMT */
@@ -2434,39 +2434,39 @@
fd := self fileDescriptorOrNil.
fd isNil ifTrue:[
- ^ self
+ ^ self
].
%{
#ifdef SUPPORT_DEV_AUDIO
if (__isSmallInteger(fd) && __isSmallInteger(nChannels)) {
- int f = __intVal(fd);
- int __nCh = __intVal(nChannels);
+ int f = __intVal(fd);
+ int __nCh = __intVal(nChannels);
# ifdef SNDCTL_DSP_STEREO
- if ((__nCh == 1) || (__nCh == 2)) {
- int __stereo = (__nCh == 2) ? 1 : 0;
-
- if (ioctl(f, SNDCTL_DSP_STEREO, &__stereo) >= 0) {
- if (__stereo == 0) {
- __INST(numberOfChannels) = __MKSMALLINT(1);
- } else {
- __INST(numberOfChannels) = __MKSMALLINT(2);
- }
- RETURN (self);
- }
- }
+ if ((__nCh == 1) || (__nCh == 2)) {
+ int __stereo = (__nCh == 2) ? 1 : 0;
+
+ if (ioctl(f, SNDCTL_DSP_STEREO, &__stereo) >= 0) {
+ if (__stereo == 0) {
+ __INST(numberOfChannels) = __MKSMALLINT(1);
+ } else {
+ __INST(numberOfChannels) = __MKSMALLINT(2);
+ }
+ RETURN (self);
+ }
+ }
# else
# ifdef SOUND_PCM_WRITE_CHANNELS
- if (ioctl(f, SOUND_PCM_WRITE_CHANNELS, &__nCh) >= 0) {
- RETURN (self);
- }
+ if (ioctl(f, SOUND_PCM_WRITE_CHANNELS, &__nCh) >= 0) {
+ RETURN (self);
+ }
# else
# ifdef AUDIO_SET_CHANNELS /* hpux */
- if (ioctl (f, AUDIO_SET_CHANNELS, __nCh)) {
- /* console_fprintf(stderr, "got err-ret from AUDIO_SET_CHANNELS\n"); */
- RETURN (self);
- }
+ if (ioctl (f, AUDIO_SET_CHANNELS, __nCh)) {
+ /* console_fprintf(stderr, "got err-ret from AUDIO_SET_CHANNELS\n"); */
+ RETURN (self);
+ }
# endif
# endif
# endif
@@ -2490,7 +2490,7 @@
fd := self fileDescriptorOrNil.
fd isNil ifTrue:[
- ^ self
+ ^ self
].
%{
@@ -2499,17 +2499,17 @@
int __blockSize = __intVal(blockSize);
if (__isSmallInteger(fd) && __isSmallInteger(blockSize)) {
- __blockSize = __intVal(blockSize);
+ __blockSize = __intVal(blockSize);
# if defined(SNDCTL_DSP_SETFRAGMENT)
- if (ioctl(f, SNDCTL_DSP_SETFRAGMENT, &__blockSize) >= 0) {
- RETURN (self);
- }
+ if (ioctl(f, SNDCTL_DSP_SETFRAGMENT, &__blockSize) >= 0) {
+ RETURN (self);
+ }
# endif
# ifdef AUDIO_SET_CHANNELS /* hpux */
- if (ioctl (f, AUDIO_SET_TXBUFSIZE, __blockSize)) {
- /* console_fprintf(stderr, "got err-ret from AUDIO_SET_TXBUFSIZE\n"); */
- RETURN (self);
- }
+ if (ioctl (f, AUDIO_SET_TXBUFSIZE, __blockSize)) {
+ /* console_fprintf(stderr, "got err-ret from AUDIO_SET_TXBUFSIZE\n"); */
+ RETURN (self);
+ }
# endif
}
#endif // SUPPORT_DEV_AUDIO
@@ -2525,7 +2525,7 @@
fd := self fileDescriptorOrNil.
fd isNil ifTrue:[
- ^ self
+ ^ self
].
%{
#ifdef SUPPORT_DEV_AUDIO
@@ -2533,34 +2533,34 @@
int __rate = __intVal(hz);
if (__isSmallInteger(fd) && __isSmallInteger(hz)) {
- int __rateWant = __rate;
+ int __rateWant = __rate;
# if defined(SNDCTL_DSP_SPEED)
- if (ioctl(f, SNDCTL_DSP_SPEED, &__rate) >= 0) {
- if (__rate != __rateWant) {
- console_fprintf(stderr, "SoundStream [warning]: actual rate is %d\n", __rate);
- hz = __MKSMALLINT(__rate);
- }
- __INST(sampleRate) = hz;
- RETURN (self);
- }
+ if (ioctl(f, SNDCTL_DSP_SPEED, &__rate) >= 0) {
+ if (__rate != __rateWant) {
+ console_fprintf(stderr, "SoundStream [warning]: actual rate is %d\n", __rate);
+ hz = __MKSMALLINT(__rate);
+ }
+ __INST(sampleRate) = hz;
+ RETURN (self);
+ }
# else
# if defined(SOUND_PCM_WRITE_RATE)
- if (ioctl(f, SOUND_PCM_WRITE_RATE, &__rate) >= 0) {
- if (__rate != __rateWant) {
- console_fprintf(stderr, "SoundStream [warning]: actual rate is %d\n", __rate);
- hz = __MKSMALLINT(__rate);
- }
- __INST(sampleRate) = hz;
- RETURN (self);
- }
+ if (ioctl(f, SOUND_PCM_WRITE_RATE, &__rate) >= 0) {
+ if (__rate != __rateWant) {
+ console_fprintf(stderr, "SoundStream [warning]: actual rate is %d\n", __rate);
+ hz = __MKSMALLINT(__rate);
+ }
+ __INST(sampleRate) = hz;
+ RETURN (self);
+ }
# else
# ifdef AUDIO_SET_SAMPLE_RATE /* hpux */
- if (ioctl (f, AUDIO_SET_SAMPLE_RATE, __rate)) {
- /* console_fprintf(stderr, "got err-ret from AUDIO_SET_SAMPLE_RATE\n"); */
- __INST(sampleRate) = hz;
- RETURN (self);
- }
+ if (ioctl (f, AUDIO_SET_SAMPLE_RATE, __rate)) {
+ /* console_fprintf(stderr, "got err-ret from AUDIO_SET_SAMPLE_RATE\n"); */
+ __INST(sampleRate) = hz;
+ RETURN (self);
+ }
# endif
# endif
# endif
@@ -2580,25 +2580,25 @@
supportedAudioFormats
"return a collection of supported audio formats.
possibly returned symbols are:
- U8 unsigned 8bit samples
- S8 signed 8bit samples
- U16 unsigned 16bit samples in native format
- U16_LE unsigned 16bit big endian samples
- U16_BE unsigned 16bit big endian samples
- S16 signed 16bit little endian samples in native format
- S16_LE signed 16bit little endian samples
- S16_BE signed 16bit big endian samples
- S24 signed 24bit little endian samples in native format
- S24_LE signed 24bit little endian samples
- S24_BE signed 24bit big endian samples
- S32 signed 32bit little endian samples in native format
- S32_LE signed 32bit little endian samples
- S32_BE signed 32bit big endian samples
- F32 float samples
- MPEG audio mpeg encoded
- MU_LAW u-law encoded 8bit samples
- A_LAW a-law encoded 8bit samples
- IMA_ADPCM adpcm encoded
+ U8 unsigned 8bit samples
+ S8 signed 8bit samples
+ U16 unsigned 16bit samples in native format
+ U16_LE unsigned 16bit big endian samples
+ U16_BE unsigned 16bit big endian samples
+ S16 signed 16bit little endian samples in native format
+ S16_LE signed 16bit little endian samples
+ S16_BE signed 16bit big endian samples
+ S24 signed 24bit little endian samples in native format
+ S24_LE signed 24bit little endian samples
+ S24_BE signed 24bit big endian samples
+ S32 signed 32bit little endian samples in native format
+ S32_LE signed 32bit little endian samples
+ S32_BE signed 32bit big endian samples
+ F32 float samples
+ MPEG audio mpeg encoded
+ MU_LAW u-law encoded 8bit samples
+ A_LAW a-law encoded 8bit samples
+ IMA_ADPCM adpcm encoded
the set of returned symbols depends on the underlying sound hardware.
"
@@ -2622,44 +2622,44 @@
supports_MU_LAW = true;
if (fd != nil) {
- int f = __intVal(fd);
- int __audioFormatMask = 0;
+ int f = __intVal(fd);
+ int __audioFormatMask = 0;
# if defined(SNDCTL_DSP_GETFMTS)
- if (ioctl(f, SNDCTL_DSP_GETFMTS, &__audioFormatMask) >= 0) {
- audioFormatMask = __MKSMALLINT(__audioFormatMask);
+ if (ioctl(f, SNDCTL_DSP_GETFMTS, &__audioFormatMask) >= 0) {
+ audioFormatMask = __MKSMALLINT(__audioFormatMask);
# ifdef AFMT_MU_LAW
- supports_MU_LAW = (__audioFormatMask & AFMT_MU_LAW) ? true : false;
+ supports_MU_LAW = (__audioFormatMask & AFMT_MU_LAW) ? true : false;
# endif
# ifdef AFMT_A_LAW
- supports_A_LAW = (__audioFormatMask & AFMT_A_LAW) ? true : false;
+ supports_A_LAW = (__audioFormatMask & AFMT_A_LAW) ? true : false;
# endif
# ifdef AFMT_IMA_ADPCM
- supports_IMA_ADPCM = (__audioFormatMask & AFMT_IMA_ADPCM) ? true : false;
+ supports_IMA_ADPCM = (__audioFormatMask & AFMT_IMA_ADPCM) ? true : false;
# endif
# ifdef AFMT_U8
- supports_U8 = (__audioFormatMask & AFMT_U8) ? true : false;
+ supports_U8 = (__audioFormatMask & AFMT_U8) ? true : false;
# endif
# ifdef AFMT_S16_LE
- supports_S16_LE = (__audioFormatMask & AFMT_S16_LE) ? true : false;
+ supports_S16_LE = (__audioFormatMask & AFMT_S16_LE) ? true : false;
# endif
# ifdef AFMT_S16_BE
- supports_S16_BE = (__audioFormatMask & AFMT_S16_BE) ? true : false;
+ supports_S16_BE = (__audioFormatMask & AFMT_S16_BE) ? true : false;
# endif
# ifdef AFMT_S8
- supports_S8 = (__audioFormatMask & AFMT_S8) ? true : false;
+ supports_S8 = (__audioFormatMask & AFMT_S8) ? true : false;
# endif
# ifdef AFMT_U16_LE
- supports_U16_LE = (__audioFormatMask & AFMT_U16_LE) ? true : false;
+ supports_U16_LE = (__audioFormatMask & AFMT_U16_LE) ? true : false;
# endif
# ifdef AFMT_U16_BE
- supports_U16_BE = (__audioFormatMask & AFMT_U16_BE) ? true : false;
+ supports_U16_BE = (__audioFormatMask & AFMT_U16_BE) ? true : false;
# endif
# ifdef AFMT_MPEG
- supports_MPEG = (__audioFormatMask & AFMT_MPEG) ? true : false;
+ supports_MPEG = (__audioFormatMask & AFMT_MPEG) ? true : false;
# endif
- }
+ }
}
# endif // SNDCTL_DSP_GETFMTS
@@ -2671,73 +2671,73 @@
%}.
supportedFormats := IdentitySet new.
(supports_MU_LAW ? false) ifTrue:[
- supportedFormats add:#'MU_LAW'
+ supportedFormats add:#'MU_LAW'
].
(supports_A_LAW ? false) ifTrue:[
- supportedFormats add:#'A_LAW'
+ supportedFormats add:#'A_LAW'
].
(supports_IMA_ADPCM ? false) ifTrue:[
- supportedFormats add:#'IMA_ADPCM'
+ supportedFormats add:#'IMA_ADPCM'
].
(supports_MPEG ? false) ifTrue:[
- supportedFormats add:#'MPEG'
+ supportedFormats add:#'MPEG'
].
(supports_S8 ? false) ifTrue:[
- supportedFormats add:#'S8'
+ supportedFormats add:#'S8'
].
(supports_U8 ? false) ifTrue:[
- supportedFormats add:#'U8'
+ supportedFormats add:#'U8'
].
(supports_S16_LE ? false) ifTrue:[
- supportedFormats add:#'S16_LE'.
- UninterpretedBytes isBigEndian ifFalse:[
- supportedFormats add:#'S16'.
- ]
+ supportedFormats add:#'S16_LE'.
+ UninterpretedBytes isBigEndian ifFalse:[
+ supportedFormats add:#'S16'.
+ ]
].
(supports_S16_BE ? false) ifTrue:[
- supportedFormats add:#'S16_BE'.
- UninterpretedBytes isBigEndian ifTrue:[
- supportedFormats add:#'S16'.
- ]
+ supportedFormats add:#'S16_BE'.
+ UninterpretedBytes isBigEndian ifTrue:[
+ supportedFormats add:#'S16'.
+ ]
].
(supports_S24_LE ? false) ifTrue:[
- supportedFormats add:#'S24_LE'.
- UninterpretedBytes isBigEndian ifFalse:[
- supportedFormats add:#'S24'.
- ]
+ supportedFormats add:#'S24_LE'.
+ UninterpretedBytes isBigEndian ifFalse:[
+ supportedFormats add:#'S24'.
+ ]
].
(supports_S24_BE ? false) ifTrue:[
- supportedFormats add:#'S24_BE'.
- UninterpretedBytes isBigEndian ifTrue:[
- supportedFormats add:#'S24'.
- ]
+ supportedFormats add:#'S24_BE'.
+ UninterpretedBytes isBigEndian ifTrue:[
+ supportedFormats add:#'S24'.
+ ]
].
(supports_S32_LE ? false) ifTrue:[
- supportedFormats add:#'S32_LE'.
- UninterpretedBytes isBigEndian ifFalse:[
- supportedFormats add:#'S32'.
- ]
+ supportedFormats add:#'S32_LE'.
+ UninterpretedBytes isBigEndian ifFalse:[
+ supportedFormats add:#'S32'.
+ ]
].
(supports_S32_BE ? false) ifTrue:[
- supportedFormats add:#'S32_BE'.
- UninterpretedBytes isBigEndian ifTrue:[
- supportedFormats add:#'S32'.
- ]
+ supportedFormats add:#'S32_BE'.
+ UninterpretedBytes isBigEndian ifTrue:[
+ supportedFormats add:#'S32'.
+ ]
].
(supports_U16_LE ? false) ifTrue:[
- supportedFormats add:#'U16_LE'.
- UninterpretedBytes isBigEndian ifFalse:[
- supportedFormats add:#'U16'.
- ]
+ supportedFormats add:#'U16_LE'.
+ UninterpretedBytes isBigEndian ifFalse:[
+ supportedFormats add:#'U16'.
+ ]
].
(supports_U16_BE ? false) ifTrue:[
- supportedFormats add:#'U16_BE'.
- UninterpretedBytes isBigEndian ifTrue:[
- supportedFormats add:#'U16'.
- ]
+ supportedFormats add:#'U16_BE'.
+ UninterpretedBytes isBigEndian ifTrue:[
+ supportedFormats add:#'U16'.
+ ]
].
(supports_F32 ? false) ifTrue:[
- supportedFormats add:#'F32'
+ supportedFormats add:#'F32'
].
^ supportedFormats.
@@ -2774,47 +2774,47 @@
int fd;
if ((fp = __INST(handle)) != nil) {
- f = __FILEVal(fp);
- if (__INST(mode) != @symbol(writeonly)) {
- if (__bothSmallInteger(count, start)) {
- cnt = __intVal(count);
- offs = __intVal(start) - 1;
-
- objSize = _Size(anObject) - OHDR_SIZE;
- if ( (offs >= 0) && (cnt >= 0) && (objSize >= (cnt + offs)) ) {
- do {
- cp = (char *)__InstPtr(anObject) + OHDR_SIZE + offs;
-
- n = cnt;
+ f = __FILEVal(fp);
+ if (__INST(mode) != @symbol(writeonly)) {
+ if (__bothSmallInteger(count, start)) {
+ cnt = __intVal(count);
+ offs = __intVal(start) - 1;
+
+ objSize = _Size(anObject) - OHDR_SIZE;
+ if ( (offs >= 0) && (cnt >= 0) && (objSize >= (cnt + offs)) ) {
+ do {
+ cp = (char *)__InstPtr(anObject) + OHDR_SIZE + offs;
+
+ n = cnt;
# ifdef LINUX
- sigsetmask(~0);
+ sigsetmask(~0);
# endif
- if (__INST(buffered) == true) {
- n = fread(cp, 1, n, f);
- } else {
- fd = fileno(f);
- n = read(fd, cp, n);
- }
+ if (__INST(buffered) == true) {
+ n = fread(cp, 1, n, f);
+ } else {
+ fd = fileno(f);
+ n = read(fd, cp, n);
+ }
# ifdef LINUX
- sigsetmask(0);
+ sigsetmask(0);
# endif
- __BEGIN_INTERRUPTABLE__
- __END_INTERRUPTABLE__
- // console_fprintf(stderr, "SoundStream: read %d bytes\n", n);
- if (n > 0) {
- offs += n;
- cnt -= n;
- } else {
- if (n < 0) {
- console_fprintf(stderr, "read error: %d\n", __threadErrno);
- RETURN (count);
- }
- }
- } while (cnt);
- }
- RETURN (count);
- }
- }
+ __BEGIN_INTERRUPTABLE__
+ __END_INTERRUPTABLE__
+ // console_fprintf(stderr, "SoundStream: read %d bytes\n", n);
+ if (n > 0) {
+ offs += n;
+ cnt -= n;
+ } else {
+ if (n < 0) {
+ console_fprintf(stderr, "read error: %d\n", __threadErrno);
+ RETURN (count);
+ }
+ }
+ } while (cnt);
+ }
+ RETURN (count);
+ }
+ }
}
#endif /* SUPPORT_DEV_AUDIO */
@@ -2849,46 +2849,46 @@
int fd;
if ((fp = __INST(handle)) != nil) {
- f = __FILEVal(fp);
- if (__INST(mode) != @symbol(readonly)) {
- if (__bothSmallInteger(count, start)) {
- cnt = __intVal(count);
- offs = __intVal(start) - 1;
-
- objSize = _Size(anObject) - OHDR_SIZE;
- if ( (offs >= 0) && (cnt >= 0) && (objSize >= (cnt + offs)) ) {
- do {
- cp = (char *)__InstPtr(anObject) + OHDR_SIZE + offs;
-
- n = cnt;
+ f = __FILEVal(fp);
+ if (__INST(mode) != @symbol(readonly)) {
+ if (__bothSmallInteger(count, start)) {
+ cnt = __intVal(count);
+ offs = __intVal(start) - 1;
+
+ objSize = _Size(anObject) - OHDR_SIZE;
+ if ( (offs >= 0) && (cnt >= 0) && (objSize >= (cnt + offs)) ) {
+ do {
+ cp = (char *)__InstPtr(anObject) + OHDR_SIZE + offs;
+
+ n = cnt;
# ifdef LINUX
- sigsetmask(~0);
+ sigsetmask(~0);
# endif
- if (__INST(buffered) == true) {
- n = fwrite(cp, 1, n, f);
- } else {
- fd = fileno(f);
- n = write(fd, cp, n);
- }
+ if (__INST(buffered) == true) {
+ n = fwrite(cp, 1, n, f);
+ } else {
+ fd = fileno(f);
+ n = write(fd, cp, n);
+ }
# ifdef LINUX
- sigsetmask(0);
+ sigsetmask(0);
# endif
- __BEGIN_INTERRUPTABLE__
- __END_INTERRUPTABLE__
- if (n > 0) {
- offs += n;
- cnt -= n;
- } else {
- if (n < 0) {
- console_fprintf(stderr, "write error: %d\n", __threadErrno);
- RETURN (count);
- }
- }
- } while (cnt);
- }
- RETURN (count);
- }
- }
+ __BEGIN_INTERRUPTABLE__
+ __END_INTERRUPTABLE__
+ if (n > 0) {
+ offs += n;
+ cnt -= n;
+ } else {
+ if (n < 0) {
+ console_fprintf(stderr, "write error: %d\n", __threadErrno);
+ RETURN (count);
+ }
+ }
+ } while (cnt);
+ }
+ RETURN (count);
+ }
+ }
}
#endif /* SUPPORT_DEV_AUDIO */
@@ -2903,25 +2903,25 @@
documentation to be added.
class:
- <a short class summary here, describing what instances represent>
+ <a short class summary here, describing what instances represent>
responsibilities:
- <describing what my main role is>
+ <describing what my main role is>
collaborators:
- <describing with whom and how I talk to>
+ <describing with whom and how I talk to>
API:
- <public api and main messages>
+ <public api and main messages>
example:
- <a one-line examples on how to use - can also be in a separate example method>
+ <a one-line examples on how to use - can also be in a separate example method>
implementation:
- <implementation points>
+ <implementation points>
[author:]
- exept MBP
+ exept MBP
[instance variables:]
@@ -2954,10 +2954,10 @@
ALport p;
if ((port = __INST(alPort)) != nil) {
- p = __ALportVal(port);
- while (ALgetfilled(p) > 0) {
- sginap(1);
- }
+ p = __ALportVal(port);
+ while (ALgetfilled(p) > 0) {
+ sginap(1);
+ }
}
RETURN(self);
#endif /* SUPPORT_IRIS_AUDIO */
@@ -2975,8 +2975,8 @@
OBJ port;
if ((port = __INST(alPort)) != nil) {
- __INST(alPort) = nil;
- ALcloseport(__ALportVal(port));
+ __INST(alPort) = nil;
+ ALcloseport(__ALportVal(port));
}
RETURN (self);
#endif /* SUPPORT_IRIS_AUDIO */
@@ -2992,34 +2992,34 @@
ALconfig config;
ALport p;
long params[] = {
- AL_INPUT_SOURCE, AL_INPUT_MIC,
- AL_INPUT_RATE, 8000,
- AL_OUTPUT_RATE, 8000,
+ AL_INPUT_SOURCE, AL_INPUT_MIC,
+ AL_INPUT_RATE, 8000,
+ AL_OUTPUT_RATE, 8000,
};
ok = false.
config = ALnewconfig();
if (__INST(numberOfChannels) == __MKSMALLINT(2))
- ALsetchannels(config, AL_STEREO);
+ ALsetchannels(config, AL_STEREO);
else
- ALsetchannels(config, AL_MONO);
+ ALsetchannels(config, AL_MONO);
if (__INST(bitsPerSample) == __MKSMALLINT(16))
- ALsetwidth(config, AL_SAMPLE_16);
+ ALsetwidth(config, AL_SAMPLE_16);
else
- ALsetwidth(config, AL_SAMPLE_8);
+ ALsetwidth(config, AL_SAMPLE_8);
if (__isSmallInteger(__INST(sampleRate)))
- params[3] = params[5] = __intVal(__INST(sampleRate));
+ params[3] = params[5] = __intVal(__INST(sampleRate));
ALsetparams(AL_DEFAULT_DEVICE, params, 6);
p = ALopenport("smallchat", (char *)_stringVal(aMode), config);
if (p) {
- OBJ t;
-
- t = __MKEXTERNALADDRESS(p); __INST(alPort) = t; __STORE(self, t);
+ OBJ t;
+
+ t = __MKEXTERNALADDRESS(p); __INST(alPort) = t; __STORE(self, t);
} else {
- __INST(alPort) = nil;
- goto out;
+ __INST(alPort) = nil;
+ goto out;
}
__INST(binary) = true;
@@ -3029,27 +3029,27 @@
*/
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;
+ 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;
+ 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]);
@@ -3061,11 +3061,11 @@
%}.
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.
! !
@@ -3075,25 +3075,25 @@
supportedAudioFormats
"return a collection of supported audio formats.
possibly returned symbols are:
- U8 unsigned 8bit samples
- S8 signed 8bit samples
- U16 unsigned 16bit samples in native format
- U16_LE unsigned 16bit big endian samples
- U16_BE unsigned 16bit big endian samples
- S16 signed 16bit little endian samples in native format
- S16_LE signed 16bit little endian samples
- S16_BE signed 16bit big endian samples
- S24 signed 24bit little endian samples in native format
- S24_LE signed 24bit little endian samples
- S24_BE signed 24bit big endian samples
- S32 signed 32bit little endian samples in native format
- S32_LE signed 32bit little endian samples
- S32_BE signed 32bit big endian samples
- F32 float samples
- MPEG audio mpeg encoded
- MU_LAW u-law encoded 8bit samples
- A_LAW a-law encoded 8bit samples
- IMA_ADPCM adpcm encoded
+ U8 unsigned 8bit samples
+ S8 signed 8bit samples
+ U16 unsigned 16bit samples in native format
+ U16_LE unsigned 16bit big endian samples
+ U16_BE unsigned 16bit big endian samples
+ S16 signed 16bit little endian samples in native format
+ S16_LE signed 16bit little endian samples
+ S16_BE signed 16bit big endian samples
+ S24 signed 24bit little endian samples in native format
+ S24_LE signed 24bit little endian samples
+ S24_BE signed 24bit big endian samples
+ S32 signed 32bit little endian samples in native format
+ S32_LE signed 32bit little endian samples
+ S32_BE signed 32bit big endian samples
+ F32 float samples
+ MPEG audio mpeg encoded
+ MU_LAW u-law encoded 8bit samples
+ A_LAW a-law encoded 8bit samples
+ IMA_ADPCM adpcm encoded
the set of returned symbols depends on the underlying sound hardware.
"
@@ -3126,23 +3126,23 @@
char *cp;
if ((port = __INST(alPort)) != nil) {
- if (__INST(mode) != _writeonly) {
- if (__bothSmallInteger(count, start)) {
- cnt = __intVal(count);
- offs = __intVal(start) - 1;
- p = __ALportVal(port);
- 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))
- nSamp = cnt / 2;
- else
- nSamp = cnt;
- ALreadsamps(p, cp, nSamp);
- RETURN ( __MKSMALLINT(cnt) );
- }
- }
- }
+ if (__INST(mode) != _writeonly) {
+ if (__bothSmallInteger(count, start)) {
+ cnt = __intVal(count);
+ offs = __intVal(start) - 1;
+ p = __ALportVal(port);
+ 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))
+ nSamp = cnt / 2;
+ else
+ nSamp = cnt;
+ ALreadsamps(p, cp, nSamp);
+ RETURN ( __MKSMALLINT(cnt) );
+ }
+ }
+ }
}
}
#endif /* SUPPORT_IRIS_AUDIO */
@@ -3169,27 +3169,27 @@
char *cp;
if ((port = __INST(alPort)) != nil) {
- if (__INST(mode) != @symbol(readonly)) {
- if (__bothSmallInteger(count, start)) {
- cnt = __intVal(count);
- offs = __intVal(start) - 1;
- p = __ALportVal(port);
-
- /*
- * 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))
- nSamp = cnt / 2;
- else
- nSamp = cnt;
- ALwritesamps(p, cp, cnt);
- RETURN ( count );
- }
- }
- }
+ if (__INST(mode) != @symbol(readonly)) {
+ if (__bothSmallInteger(count, start)) {
+ cnt = __intVal(count);
+ offs = __intVal(start) - 1;
+ p = __ALportVal(port);
+
+ /*
+ * 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))
+ nSamp = cnt / 2;
+ else
+ nSamp = cnt;
+ ALwritesamps(p, cp, cnt);
+ RETURN ( count );
+ }
+ }
+ }
}
}
#endif /* SUPPORT_IRIS_AUDIO */
@@ -3218,25 +3218,25 @@
documentation to be added.
class:
- <a short class summary here, describing what instances represent>
+ <a short class summary here, describing what instances represent>
responsibilities:
- <describing what my main role is>
+ <describing what my main role is>
collaborators:
- <describing with whom and how I talk to>
+ <describing with whom and how I talk to>
API:
- <public api and main messages>
+ <public api and main messages>
example:
- <a one-line examples on how to use - can also be in a separate example method>
+ <a one-line examples on how to use - can also be in a separate example method>
implementation:
- <implementation points>
+ <implementation points>
[author:]
- exept MBP
+ exept MBP
[instance variables:]
@@ -3257,16 +3257,16 @@
PaError paErr = 0;
if (DEBUGGING) {
- fprintf(stderr, "calling Pa_Initialize...\n");
+ fprintf(stderr, "calling Pa_Initialize...\n");
}
if ((paErr = Pa_Initialize()) != paNoError ) {
- errorMessageOrNil = __MKSTRING(Pa_GetErrorText( paErr ) );
- fprintf(stderr, "SoundStream [error]: Pa_Initialize failed\n");
+ errorMessageOrNil = __MKSTRING(Pa_GetErrorText( paErr ) );
+ fprintf(stderr, "SoundStream [error]: Pa_Initialize failed\n");
};
#endif
%}.
errorMessageOrNil notNil ifTrue:[
- self error:'failed to initialize audio device: ',errorMessageOrNil
+ self error:'failed to initialize audio device: ',errorMessageOrNil
].
! !
@@ -3291,14 +3291,14 @@
#ifdef SUPPORT_PORTAUDIO
OBJ str;
if ((str = __INST(handle1)) != nil) {
- struct paStreamData* paStreamData = (struct paStreamData*)__externalAddressVal(str);
-
- while (paStreamData->currentBuffer != NULL) {
- struct timespec a;
- a.tv_sec = 0;
- a.tv_nsec = 1 * 1000000; // 1 milliseconds asNanoseconds -> 1000000
- nanosleep( &a, NULL );
- }
+ struct paStreamData* paStreamData = (struct paStreamData*)__externalAddressVal(str);
+
+ while (paStreamData->currentBuffer != NULL) {
+ struct timespec a;
+ a.tv_sec = 0;
+ a.tv_nsec = 1 * 1000000; // 1 milliseconds asNanoseconds -> 1000000
+ nanosleep( &a, NULL );
+ }
}
#endif /* SUPPORT_PORTAUDIO */
%}.
@@ -3314,40 +3314,40 @@
#ifdef SUPPORT_PORTAUDIO
OBJ str;
if ((str = __INST(handle1)) != nil) {
- struct paStreamData* paStreamData = (struct paStreamData*)__externalAddressVal(str);
- struct paBuffer* buffer;
-
- if (DEBUGGING) {
- fprintf(stderr, "pa close\n");
- }
- __externalAddressVal(str) = NULL;
- __INST(handle1) = nil;
- // Pa_StopStream( paStreamData->stream );
- Pa_CloseStream( paStreamData->stream );
-
- LOCK(paStreamData->lock);
-
- buffer = paStreamData->currentBuffer;
- paStreamData->currentBuffer = NULL;
- paStreamData->lastBuffer = NULL;
- while (buffer != NULL) {
- struct paBuffer* nextBuffer = buffer->nextBuffer;
- free(buffer->sampleData);
- free(buffer);
- buffer = nextBuffer;
- }
- buffer = paStreamData->freeList;
- paStreamData->freeList = NULL;
- while (buffer != NULL) {
- struct paBuffer* nextBuffer = buffer->nextBuffer;
- free(buffer->sampleData);
- free(buffer);
- buffer = nextBuffer;
- }
-
- UNLOCK(paStreamData->lock);
- RELEASELOCK(paStreamData->lock);
- free(paStreamData);
+ struct paStreamData* paStreamData = (struct paStreamData*)__externalAddressVal(str);
+ struct paBuffer* buffer;
+
+ if (DEBUGGING) {
+ fprintf(stderr, "pa close\n");
+ }
+ __externalAddressVal(str) = NULL;
+ __INST(handle1) = nil;
+ // Pa_StopStream( paStreamData->stream );
+ Pa_CloseStream( paStreamData->stream );
+
+ LOCK(paStreamData->lock);
+
+ buffer = paStreamData->currentBuffer;
+ paStreamData->currentBuffer = NULL;
+ paStreamData->lastBuffer = NULL;
+ while (buffer != NULL) {
+ struct paBuffer* nextBuffer = buffer->nextBuffer;
+ free(buffer->sampleData);
+ free(buffer);
+ buffer = nextBuffer;
+ }
+ buffer = paStreamData->freeList;
+ paStreamData->freeList = NULL;
+ while (buffer != NULL) {
+ struct paBuffer* nextBuffer = buffer->nextBuffer;
+ free(buffer->sampleData);
+ free(buffer);
+ buffer = nextBuffer;
+ }
+
+ UNLOCK(paStreamData->lock);
+ RELEASELOCK(paStreamData->lock);
+ free(paStreamData);
}
RETURN (self);
#endif // SUPPORT_PORTAUDIO
@@ -3373,15 +3373,15 @@
/* default output device */
outputParameters.device = Pa_GetDefaultOutputDevice();
if (outputParameters.device == paNoDevice) {
- fprintf(stderr, "SoundStream [warning]: No default output device.\n");
- errorStringOrNil = __MKSTRING("No default output device");
- goto out;
+ fprintf(stderr, "SoundStream [warning]: No default output device.\n");
+ errorStringOrNil = __MKSTRING("No default output device");
+ goto out;
}
if (__isSmallInteger(__INST(numberOfChannels))) {
- nChannels = __intVal(__INST(numberOfChannels));
+ nChannels = __intVal(__INST(numberOfChannels));
} else {
- nChannels = 1;
+ nChannels = 1;
}
outputParameters.channelCount = nChannels;
outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency;
@@ -3394,58 +3394,58 @@
// paUInt8 is an unsigned 8 bit format where 128 is considered "ground"
if (__INST(audioFormat) == @symbol(S16)) {
- outputParameters.sampleFormat = paInt16;
- bytesPerSample = 2;
+ outputParameters.sampleFormat = paInt16;
+ bytesPerSample = 2;
} else if (__INST(audioFormat) == @symbol(S32)) {
- outputParameters.sampleFormat = paInt32;
- bytesPerSample = 4;
+ outputParameters.sampleFormat = paInt32;
+ bytesPerSample = 4;
} else if (__INST(audioFormat) == @symbol(S24)) {
- outputParameters.sampleFormat = paInt24;
- bytesPerSample = 3;
+ outputParameters.sampleFormat = paInt24;
+ bytesPerSample = 3;
} else if (__INST(audioFormat) == @symbol(S8)) {
- outputParameters.sampleFormat = paInt8;
- bytesPerSample = 1;
+ outputParameters.sampleFormat = paInt8;
+ bytesPerSample = 1;
} else if (__INST(audioFormat) == @symbol(F32)) {
- outputParameters.sampleFormat = paFloat32;
- bytesPerSample = 4;
+ outputParameters.sampleFormat = paFloat32;
+ bytesPerSample = 4;
} else if (__INST(audioFormat) == @symbol(U8)) {
- outputParameters.sampleFormat = paUInt8;
- bytesPerSample = 1;
+ outputParameters.sampleFormat = paUInt8;
+ bytesPerSample = 1;
} else {
- fprintf(stderr, "SoundStream [warning]: unknown format - using U8\n");
- outputParameters.sampleFormat = paUInt8;
- bytesPerSample = 1;
+ fprintf(stderr, "SoundStream [warning]: unknown format - using U8\n");
+ outputParameters.sampleFormat = paUInt8;
+ bytesPerSample = 1;
}
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;
}
paStreamData = (struct paStreamData*)malloc(sizeof(struct paStreamData));
if (paStreamData == NULL) {
- fprintf(stderr, "SoundStream [warning]: failed to allocate paStream\n");
- errorStringOrNil = __MKSTRING("failed to allocate paStream");
- goto out;
+ fprintf(stderr, "SoundStream [warning]: failed to allocate paStream\n");
+ errorStringOrNil = __MKSTRING("failed to allocate paStream");
+ goto out;
}
paErr = Pa_OpenStream(
- &stream,
- NULL, /* no input */
- &outputParameters,
- sampleRate,
- FRAMES_PER_BUFFER,
- paClipOff, /* we won't output out of range samples so don't bother clipping them */
- paCallback,
- paStreamData );
+ &stream,
+ NULL, /* no input */
+ &outputParameters,
+ sampleRate,
+ FRAMES_PER_BUFFER,
+ paClipOff, /* we won't output out of range samples so don't bother clipping them */
+ paCallback,
+ paStreamData );
if (paErr != paNoError) {
- fprintf(stderr, "SoundStream [warning]: openStream: %s\n", Pa_GetErrorText( paErr ));
- free(paStreamData);
- errorStringOrNil = __MKSTRING(Pa_GetErrorText( paErr ));
- goto out;
+ fprintf(stderr, "SoundStream [warning]: openStream: %s\n", Pa_GetErrorText( paErr ));
+ free(paStreamData);
+ errorStringOrNil = __MKSTRING(Pa_GetErrorText( paErr ));
+ goto out;
}
paStreamData->stream = stream;
INITLOCK(paStreamData->lock);
@@ -3459,17 +3459,17 @@
paStreamData->hasFinished = 0;
{
- OBJ t;
- t = __MKEXTERNALADDRESS(paStreamData); __INST(handle1) = t; __STORE(self, t);
+ OBJ t;
+ t = __MKEXTERNALADDRESS(paStreamData); __INST(handle1) = t; __STORE(self, t);
}
__INST(binary) = true;
paErr = Pa_SetStreamFinishedCallback( stream, &paStreamFinished );
if( paErr != paNoError ) {
- fprintf(stderr, "SoundStream [warning]: setFinishedCallback: %s\n", Pa_GetErrorText( paErr ));
- free(paStreamData);
- errorStringOrNil = __MKSTRING(Pa_GetErrorText( paErr ));
- goto out;
+ fprintf(stderr, "SoundStream [warning]: setFinishedCallback: %s\n", Pa_GetErrorText( paErr ));
+ free(paStreamData);
+ errorStringOrNil = __MKSTRING(Pa_GetErrorText( paErr ));
+ goto out;
};
ok = true;
@@ -3478,11 +3478,11 @@
%}.
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.
@@ -3502,7 +3502,7 @@
super initialize.
(IsInitialized ? false) ifFalse:[
- self class primitiveInitializeDevice
+ self class primitiveInitializeDevice
].
"Created: 17.11.1995 / 17:28:14 / cg"
@@ -3533,25 +3533,25 @@
supportedAudioFormats
"return a collection of supported audio formats.
possibly returned symbols are:
- U8 unsigned 8bit samples
- S8 signed 8bit samples
- U16 unsigned 16bit samples in native format
- U16_LE unsigned 16bit big endian samples
- U16_BE unsigned 16bit big endian samples
- S16 signed 16bit little endian samples in native format
- S16_LE signed 16bit little endian samples
- S16_BE signed 16bit big endian samples
- S24 signed 24bit little endian samples in native format
- S24_LE signed 24bit little endian samples
- S24_BE signed 24bit big endian samples
- S32 signed 32bit little endian samples in native format
- S32_LE signed 32bit little endian samples
- S32_BE signed 32bit big endian samples
- F32 float samples
- MPEG audio mpeg encoded
- MU_LAW u-law encoded 8bit samples
- A_LAW a-law encoded 8bit samples
- IMA_ADPCM adpcm encoded
+ U8 unsigned 8bit samples
+ S8 signed 8bit samples
+ U16 unsigned 16bit samples in native format
+ U16_LE unsigned 16bit big endian samples
+ U16_BE unsigned 16bit big endian samples
+ S16 signed 16bit little endian samples in native format
+ S16_LE signed 16bit little endian samples
+ S16_BE signed 16bit big endian samples
+ S24 signed 24bit little endian samples in native format
+ S24_LE signed 24bit little endian samples
+ S24_BE signed 24bit big endian samples
+ S32 signed 32bit little endian samples in native format
+ S32_LE signed 32bit little endian samples
+ S32_BE signed 32bit big endian samples
+ F32 float samples
+ MPEG audio mpeg encoded
+ MU_LAW u-law encoded 8bit samples
+ A_LAW a-law encoded 8bit samples
+ IMA_ADPCM adpcm encoded
the set of returned symbols depends on the underlying sound hardware.
"
@@ -3590,74 +3590,74 @@
OBJ str;
if ((str = __INST(handle1)) != nil) {
- if (__INST(mode) != @symbol(readonly)) {
- if (__bothSmallInteger(count, start)) {
- // allocate a buffer
- struct paStreamData* paStreamData = (struct paStreamData*)__externalAddressVal(str);
- int cnt = __intVal(count);
- int offs = __intVal(start) - 1;
- int objSize;
-
- objSize = _Size(anObject) - OHDR_SIZE;
- if ( (offs >= 0) && (cnt >= 0) && (objSize >= (cnt + offs)) ) {
- struct paBuffer* newBuffer;
- struct paBuffer* toFree;
- int mustStart = 0;
- unsigned char* newSampleData;
-
- // try freeList
- LOCK(paStreamData->lock);
- if ((paStreamData->freeList != NULL)
- && (paStreamData->freeList->bufferSize == cnt)) {
- // reuse
- newBuffer = paStreamData->freeList;
- paStreamData->freeList = newBuffer->nextBuffer;
- newSampleData = newBuffer->sampleData;
- toFree = NULL;
- if (DEBUGGING) {
- fprintf(stderr, "from free: %p (->%p)\n", newBuffer, newBuffer->sampleData);
- }
- } else {
- // free them all
- toFree = paStreamData->freeList;
- paStreamData->freeList = NULL;
- newBuffer = malloc(sizeof(struct paBuffer));
- newSampleData = malloc(cnt);
- newBuffer->sampleData = newSampleData;
- newBuffer->bufferSize = cnt;
- if (DEBUGGING) {
- fprintf(stderr, "alloc: %p (->%p)\n", newBuffer, newBuffer->sampleData);
- }
- }
-
- memcpy(newSampleData, (__ByteArrayInstPtr(anObject)->ba_element)+offs, cnt);
- newBuffer->nextBuffer = NULL;
-
- if (paStreamData->lastBuffer == NULL) {
- // start stream's buffer list
- paStreamData->currentBuffer = newBuffer;
- mustStart = 1;
- } else {
- // append to stream's buffer list
- paStreamData->lastBuffer->nextBuffer = newBuffer;
- }
- paStreamData->lastBuffer = newBuffer;
- paStreamData->hasFinished = 0;
- UNLOCK(paStreamData->lock);
-
- if (mustStart) {
- PaError paErr = Pa_StartStream( paStreamData->stream );
- if ( paErr != paNoError ) {
- if (DEBUGGING) {
- fprintf(stderr, "start error\n");
- }
- RETURN (0);
- };
- }
- RETURN (count);
- }
- }
- }
+ if (__INST(mode) != @symbol(readonly)) {
+ if (__bothSmallInteger(count, start)) {
+ // allocate a buffer
+ struct paStreamData* paStreamData = (struct paStreamData*)__externalAddressVal(str);
+ int cnt = __intVal(count);
+ int offs = __intVal(start) - 1;
+ int objSize;
+
+ objSize = _Size(anObject) - OHDR_SIZE;
+ if ( (offs >= 0) && (cnt >= 0) && (objSize >= (cnt + offs)) ) {
+ struct paBuffer* newBuffer;
+ struct paBuffer* toFree;
+ int mustStart = 0;
+ unsigned char* newSampleData;
+
+ // try freeList
+ LOCK(paStreamData->lock);
+ if ((paStreamData->freeList != NULL)
+ && (paStreamData->freeList->bufferSize == cnt)) {
+ // reuse
+ newBuffer = paStreamData->freeList;
+ paStreamData->freeList = newBuffer->nextBuffer;
+ newSampleData = newBuffer->sampleData;
+ toFree = NULL;
+ if (DEBUGGING) {
+ fprintf(stderr, "from free: %p (->%p)\n", newBuffer, newBuffer->sampleData);
+ }
+ } else {
+ // free them all
+ toFree = paStreamData->freeList;
+ paStreamData->freeList = NULL;
+ newBuffer = malloc(sizeof(struct paBuffer));
+ newSampleData = malloc(cnt);
+ newBuffer->sampleData = newSampleData;
+ newBuffer->bufferSize = cnt;
+ if (DEBUGGING) {
+ fprintf(stderr, "alloc: %p (->%p)\n", newBuffer, newBuffer->sampleData);
+ }
+ }
+
+ memcpy(newSampleData, (__ByteArrayInstPtr(anObject)->ba_element)+offs, cnt);
+ newBuffer->nextBuffer = NULL;
+
+ if (paStreamData->lastBuffer == NULL) {
+ // start stream's buffer list
+ paStreamData->currentBuffer = newBuffer;
+ mustStart = 1;
+ } else {
+ // append to stream's buffer list
+ paStreamData->lastBuffer->nextBuffer = newBuffer;
+ }
+ paStreamData->lastBuffer = newBuffer;
+ paStreamData->hasFinished = 0;
+ UNLOCK(paStreamData->lock);
+
+ if (mustStart) {
+ PaError paErr = Pa_StartStream( paStreamData->stream );
+ if ( paErr != paNoError ) {
+ if (DEBUGGING) {
+ fprintf(stderr, "start error\n");
+ }
+ RETURN (0);
+ };
+ }
+ RETURN (count);
+ }
+ }
+ }
}
#endif /* SUPPORT_PORTAUDIO */
@@ -3672,25 +3672,25 @@
documentation to be added.
class:
- <a short class summary here, describing what instances represent>
+ <a short class summary here, describing what instances represent>
responsibilities:
- <describing what my main role is>
+ <describing what my main role is>
collaborators:
- <describing with whom and how I talk to>
+ <describing with whom and how I talk to>
API:
- <public api and main messages>
+ <public api and main messages>
example:
- <a one-line examples on how to use - can also be in a separate example method>
+ <a one-line examples on how to use - can also be in a separate example method>
implementation:
- <implementation points>
+ <implementation points>
[author:]
- exept MBP
+ exept MBP
[instance variables:]
@@ -3733,19 +3733,19 @@
LPDIRECTSOUNDBUFFER t_pDSBuffer;
if ((oDSBuffer = __INST(pDSBuffer)) != nil) {
- __INST(pDSBuffer) = nil;
- t_pDSBuffer = __DSBufferVal(oDSBuffer);
- if (t_pDSBuffer) {
- IDirectSoundBuffer_Stop(t_pDSBuffer);
- IDirectSoundBuffer_Release(t_pDSBuffer);
- }
+ __INST(pDSBuffer) = nil;
+ t_pDSBuffer = __DSBufferVal(oDSBuffer);
+ if (t_pDSBuffer) {
+ IDirectSoundBuffer_Stop(t_pDSBuffer);
+ IDirectSoundBuffer_Release(t_pDSBuffer);
+ }
}
if ((oDirectSound = __INST(pDirectSound)) != nil) {
- __INST(pDirectSound) = nil;
- t_pDirectSound = __DirectSoundVal(oDirectSound);
- if (t_pDirectSound) {
- IDirectSound_Release(t_pDirectSound);
- }
+ __INST(pDirectSound) = nil;
+ t_pDirectSound = __DirectSoundVal(oDirectSound);
+ if (t_pDirectSound) {
+ IDirectSound_Release(t_pDirectSound);
+ }
}
RETURN (self);
#endif /* SUPPORT_WIN32_DIRECTSOUND */
@@ -3771,8 +3771,8 @@
/* Create the DS object */
if ((result = DirectSoundCreate(NULL, &t_pDirectSound, NULL)) != DS_OK) {
- console_fprintf(stderr,"SoundStream: Cannot open default sound device!!\n");
- goto out;
+ console_fprintf(stderr,"SoundStream: Cannot open default sound device!!\n");
+ goto out;
}
/* Define the wave format structure */
@@ -3794,20 +3794,20 @@
/* Create the primary DS buffer */
if ((result = IDirectSound_CreateSoundBuffer(t_pDirectSound, &primarydsbDesc,
- &t_pDSPrimeBuffer, NULL)) != DS_OK) {
- console_fprintf(stderr,"SoundStream: Cannot get the primary DS buffer address!\n");
- IDirectSound_Release(t_pDirectSound);
- goto out;
+ &t_pDSPrimeBuffer, NULL)) != DS_OK) {
+ console_fprintf(stderr,"SoundStream: Cannot get the primary DS buffer address!\n");
+ IDirectSound_Release(t_pDirectSound);
+ goto out;
}
/* Set the primary DS buffer sound format. We have to do this because
the default primary buffer is 8-bit, 22kHz! */
if ((result = IDirectSoundBuffer_SetFormat(t_pDSPrimeBuffer, &wfFormat)) != DS_OK) {
- console_fprintf(stderr,"SoundStream: Cannot set the primary DS buffer to proper sound format (%x) (%d)!\n", result, result);
- IDirectSoundBuffer_Stop(t_pDSPrimeBuffer);
- IDirectSoundBuffer_Release(t_pDSPrimeBuffer);
- IDirectSound_Release(t_pDirectSound);
- goto out;
+ console_fprintf(stderr,"SoundStream: Cannot set the primary DS buffer to proper sound format (%x) (%d)!\n", result, result);
+ IDirectSoundBuffer_Stop(t_pDSPrimeBuffer);
+ IDirectSoundBuffer_Release(t_pDSPrimeBuffer);
+ IDirectSound_Release(t_pDirectSound);
+ goto out;
}
# endif /* 0 */
@@ -3823,18 +3823,18 @@
/* Create the secondary DS buffer */
if ((result = IDirectSound_CreateSoundBuffer(t_pDirectSound, &dsbdDesc, &t_pDSBuffer, NULL)) != DS_OK) {
- console_fprintf(stderr,"SoundStream: couldn't create sound buffer!\n");
- IDirectSoundBuffer_Stop(t_pDSPrimeBuffer);
- IDirectSoundBuffer_Release(t_pDSPrimeBuffer);
- IDirectSound_Release(t_pDirectSound);
- goto out;
+ console_fprintf(stderr,"SoundStream: couldn't create sound buffer!\n");
+ IDirectSoundBuffer_Stop(t_pDSPrimeBuffer);
+ IDirectSoundBuffer_Release(t_pDSPrimeBuffer);
+ IDirectSound_Release(t_pDirectSound);
+ goto out;
}
/* Lock the DS buffer */
if ((result = IDirectSoundBuffer_Lock(t_pDSBuffer, 0, t_cbBufSize, (LPLPVOID)&pDSBuffData,
- &dwDataLen, NULL, NULL, 0)) != DS_OK) {
- console_fprintf(stderr,"SoundStream: couldn't lock sound buffer!\n");
- goto errorAndOut;
+ &dwDataLen, NULL, NULL, 0)) != DS_OK) {
+ console_fprintf(stderr,"SoundStream: couldn't lock sound buffer!\n");
+ goto errorAndOut;
}
/* Zero the DS buffer */
@@ -3842,29 +3842,29 @@
/* Unlock the DS buffer */
if ((result = IDirectSoundBuffer_Unlock(t_pDSBuffer, pDSBuffData, dwDataLen, NULL, 0)) != DS_OK) {
- console_fprintf(stderr,"SoundStream: couldn't unlock sound buffer!\n");
- goto errorAndOut;
+ console_fprintf(stderr,"SoundStream: couldn't unlock sound buffer!\n");
+ goto errorAndOut;
}
__INST(bufferOffset) = __MKSMALLINT(0); // reset last write position to start of buffer
/* Start the buffer playback */
if ((result = IDirectSoundBuffer_Play(t_pDSBuffer, 0, 0, DSBPLAY_LOOPING) != DS_OK)) {
- console_fprintf(stderr,"SoundStream: couldn't play sound buffer!\n");
+ console_fprintf(stderr,"SoundStream: couldn't play sound buffer!\n");
errorAndOut:
- IDirectSoundBuffer_Stop(t_pDSBuffer);
- IDirectSoundBuffer_Stop(t_pDSPrimeBuffer);
- IDirectSoundBuffer_Release(t_pDSPrimeBuffer);
- IDirectSound_Release(t_pDirectSound);
- goto out;
+ IDirectSoundBuffer_Stop(t_pDSBuffer);
+ IDirectSoundBuffer_Stop(t_pDSPrimeBuffer);
+ IDirectSoundBuffer_Release(t_pDSPrimeBuffer);
+ IDirectSound_Release(t_pDirectSound);
+ goto out;
}
{
- OBJ t;
-
- t = __MKEXTERNALADDRESS(t_pDSBuffer); __INST(pDSBuffer) = t; __STORE(self, t);
- t = __MKEXTERNALADDRESS(t_pDirectSound); __INST(pDirectSound) = t; __STORE(self, t);
+ OBJ t;
+
+ t = __MKEXTERNALADDRESS(t_pDSBuffer); __INST(pDSBuffer) = t; __STORE(self, t);
+ t = __MKEXTERNALADDRESS(t_pDirectSound); __INST(pDirectSound) = t; __STORE(self, t);
}
ok = true;
out:;
@@ -3872,11 +3872,11 @@
%}.
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.
! !
@@ -3886,25 +3886,25 @@
supportedAudioFormats
"return a collection of supported audio formats.
possibly returned symbols are:
- U8 unsigned 8bit samples
- S8 signed 8bit samples
- U16 unsigned 16bit samples in native format
- U16_LE unsigned 16bit big endian samples
- U16_BE unsigned 16bit big endian samples
- S16 signed 16bit little endian samples in native format
- S16_LE signed 16bit little endian samples
- S16_BE signed 16bit big endian samples
- S24 signed 24bit little endian samples in native format
- S24_LE signed 24bit little endian samples
- S24_BE signed 24bit big endian samples
- S32 signed 32bit little endian samples in native format
- S32_LE signed 32bit little endian samples
- S32_BE signed 32bit big endian samples
- F32 float samples
- MPEG audio mpeg encoded
- MU_LAW u-law encoded 8bit samples
- A_LAW a-law encoded 8bit samples
- IMA_ADPCM adpcm encoded
+ U8 unsigned 8bit samples
+ S8 signed 8bit samples
+ U16 unsigned 16bit samples in native format
+ U16_LE unsigned 16bit big endian samples
+ U16_BE unsigned 16bit big endian samples
+ S16 signed 16bit little endian samples in native format
+ S16_LE signed 16bit little endian samples
+ S16_BE signed 16bit big endian samples
+ S24 signed 24bit little endian samples in native format
+ S24_LE signed 24bit little endian samples
+ S24_BE signed 24bit big endian samples
+ S32 signed 32bit little endian samples in native format
+ S32_LE signed 32bit little endian samples
+ S32_BE signed 32bit big endian samples
+ F32 float samples
+ MPEG audio mpeg encoded
+ MU_LAW u-law encoded 8bit samples
+ A_LAW a-law encoded 8bit samples
+ IMA_ADPCM adpcm encoded
the set of returned symbols depends on the underlying sound hardware.
"
@@ -3957,15 +3957,15 @@
int cnt, offs;
if ((oDSBuffer = __INST(pDSBuffer)) != nil) {
- t_pDSBuffer = __DSBufferVal(oDSBuffer);
+ t_pDSBuffer = __DSBufferVal(oDSBuffer);
}
if ((oDirectSound = __INST(pDirectSound)) != nil) {
- t_pDirectSound = __DirectSoundVal(oDirectSound);
+ t_pDirectSound = __DirectSoundVal(oDirectSound);
}
if (!t_pDSBuffer || !t_pDirectSound) {
- console_fprintf(stderr, "SoundStream not open!\n");
- RETURN (0);
+ console_fprintf(stderr, "SoundStream not open!\n");
+ RETURN (0);
}
t_cbBufOffset = __intVal(__INST(bufferOffset));
t_cbBufSize = __intVal(__INST(bufferSize));
@@ -3977,47 +3977,47 @@
// Should be playing, right?
hr = IDirectSoundBuffer_GetStatus(t_pDSBuffer, &status );
if (!(status && DSBSTATUS_PLAYING)) {
- console_fprintf(stderr, "Buffer not playing!\n");
- RETURN (0);
+ console_fprintf(stderr, "Buffer not playing!\n");
+ RETURN (0);
}
// Sleep until we have enough room in buffer.
hr = IDirectSoundBuffer_GetCurrentPosition(t_pDSBuffer, &playPos, &safePos );
if( hr != DS_OK ) {
- console_fprintf(stderr, "Cannot get position!\n");
- RETURN (0);
+ console_fprintf(stderr, "Cannot get position!\n");
+ RETURN (0);
}
if( playPos < t_cbBufOffset ) playPos += t_cbBufSize;
endWrite = t_cbBufOffset + (cnt * sizeof(short));
while ( playPos < endWrite ) {
- // Calculate number of milliseconds until we will have room, as
- // time = distance * (milliseconds/second) / ((bytes/sample) * (samples/second)),
- // rounded up.
- millis = (DWORD) (1.0 + ((endWrite - playPos) * 1000.0) / ( sizeof(short) * __intVal(__INST(sampleRate))));
-
- // Sleep for that long
- Sleep( millis );
-
- // Wake up, find out where we are now
- hr = IDirectSoundBuffer_GetCurrentPosition(t_pDSBuffer, &playPos, &safePos );
- if( hr != DS_OK ) {
- console_fprintf(stderr, "Cannot get position!\n");
- RETURN (0);
- }
- if( playPos < t_cbBufOffset ) playPos += t_cbBufSize; // unwrap offset
+ // Calculate number of milliseconds until we will have room, as
+ // time = distance * (milliseconds/second) / ((bytes/sample) * (samples/second)),
+ // rounded up.
+ millis = (DWORD) (1.0 + ((endWrite - playPos) * 1000.0) / ( sizeof(short) * __intVal(__INST(sampleRate))));
+
+ // Sleep for that long
+ Sleep( millis );
+
+ // Wake up, find out where we are now
+ hr = IDirectSoundBuffer_GetCurrentPosition(t_pDSBuffer, &playPos, &safePos );
+ if( hr != DS_OK ) {
+ console_fprintf(stderr, "Cannot get position!\n");
+ RETURN (0);
+ }
+ if( playPos < t_cbBufOffset ) playPos += t_cbBufSize; // unwrap offset
}
// Lock free space in the DS
hr = IDirectSoundBuffer_Lock(t_pDSBuffer, t_cbBufOffset, cnt * sizeof(short), &lpbuf1, &dwsize1, &lpbuf2, &dwsize2, 0);
if (hr == DS_OK) {
- // Copy the buffer into the DS
- CopyMemory(lpbuf1, buf, dwsize1);
- if(NULL != lpbuf2) CopyMemory(lpbuf2, buf+dwsize1, dwsize2);
-
- // Update our buffer offset and unlock sound buffer
- t_cbBufOffset = (t_cbBufOffset + dwsize1 + dwsize2) % t_cbBufSize;
- IDirectSoundBuffer_Unlock(t_pDSBuffer, lpbuf1, dwsize1, lpbuf2, dwsize2);
+ // Copy the buffer into the DS
+ CopyMemory(lpbuf1, buf, dwsize1);
+ if(NULL != lpbuf2) CopyMemory(lpbuf2, buf+dwsize1, dwsize2);
+
+ // Update our buffer offset and unlock sound buffer
+ t_cbBufOffset = (t_cbBufOffset + dwsize1 + dwsize2) % t_cbBufSize;
+ IDirectSoundBuffer_Unlock(t_pDSBuffer, lpbuf1, dwsize1, lpbuf2, dwsize2);
}
__INST(buffferOffset) = __MKSMALLINT(t_cbBufOffset);
@@ -4036,25 +4036,25 @@
documentation to be added.
class:
- <a short class summary here, describing what instances represent>
+ <a short class summary here, describing what instances represent>
responsibilities:
- <describing what my main role is>
+ <describing what my main role is>
collaborators:
- <describing with whom and how I talk to>
+ <describing with whom and how I talk to>
API:
- <public api and main messages>
+ <public api and main messages>
example:
- <a one-line examples on how to use - can also be in a separate example method>
+ <a one-line examples on how to use - can also be in a separate example method>
implementation:
- <implementation points>
+ <implementation points>
[author:]
- exept MBP
+ exept MBP
[instance variables:]
@@ -4098,41 +4098,41 @@
OBJ oWaveHandle;
if ((oWaveHandle = __INST(waveHandle)) != nil) {
- t_waveHandle = __WaveHandleVal(oWaveHandle);
+ t_waveHandle = __WaveHandleVal(oWaveHandle);
# ifdef NO_WAIT_IN_CLOSE
- /* Force cancellation of any pending buffers */
- (void)waveOutReset(t_waveHandle);
+ /* Force cancellation of any pending buffers */
+ (void)waveOutReset(t_waveHandle);
# endif
- /* Wait until all pending buffers have been freed */
- while (free_buffers < total_buffers) {
- WaitForSingleObject(free_buffer_event, INFINITE);
- }
+ /* Wait until all pending buffers have been freed */
+ while (free_buffers < total_buffers) {
+ WaitForSingleObject(free_buffer_event, INFINITE);
+ }
# ifndef NO_WAIT_IN_CLOSE
- /* Force cancellation of any pending buffers */
- (void)waveOutReset(t_waveHandle);
+ /* Force cancellation of any pending buffers */
+ (void)waveOutReset(t_waveHandle);
# endif
- /* Close the device */
- if ((r = waveOutClose(t_waveHandle)) != 0) {
- console_printf("waveOutClose\n");
- RETURN(self);
- }
-
- EnterCriticalSection(&free_list_lock);
-
- /* Free allocated buffers */
- for (bp = free_list; bp != NULL; bp = next) {
- next = bp->next;
- (void)free(bp);
- }
- free_list = NULL;
-
- LeaveCriticalSection(&free_list_lock);
-
- __INST(waveHandle) = nil;
+ /* Close the device */
+ if ((r = waveOutClose(t_waveHandle)) != 0) {
+ console_printf("waveOutClose\n");
+ RETURN(self);
+ }
+
+ EnterCriticalSection(&free_list_lock);
+
+ /* Free allocated buffers */
+ for (bp = free_list; bp != NULL; bp = next) {
+ next = bp->next;
+ (void)free(bp);
+ }
+ free_list = NULL;
+
+ LeaveCriticalSection(&free_list_lock);
+
+ __INST(waveHandle) = nil;
}
RETURN (self);
#endif /* SUPPORT_WIN32_WAVESOUND */
@@ -4153,7 +4153,7 @@
ok = false;
if ((oWaveHandle = __INST(waveHandle)) != nil) {
- goto out;
+ goto out;
}
waveFormat.wf.wFormatTag = WAVE_FORMAT_PCM;
@@ -4164,14 +4164,14 @@
waveFormat.wf.nAvgBytesPerSec = waveFormat.wf.nSamplesPerSec * waveFormat.wf.nBlockAlign;
r = waveOutOpen(&t_waveHandle,
- WAVE_MAPPER,
- (WAVEFORMAT *)&waveFormat,
- (DWORD_PTR)waveCallBack,
- (DWORD_PTR)0,
- CALLBACK_FUNCTION);
+ WAVE_MAPPER,
+ (WAVEFORMAT *)&waveFormat,
+ (DWORD_PTR)waveCallBack,
+ (DWORD_PTR)0,
+ CALLBACK_FUNCTION);
if (r != 0) {
- console_printf("waveOutOpen\n");
- goto out;
+ console_printf("waveOutOpen\n");
+ goto out;
}
(void)waveOutReset(t_waveHandle);
@@ -4183,9 +4183,9 @@
total_buffers = 0;
{
- OBJ t;
-
- t = __MKEXTERNALADDRESS(t_waveHandle); __INST(waveHandle) = t; __STORE(self, t);
+ OBJ t;
+
+ t = __MKEXTERNALADDRESS(t_waveHandle); __INST(waveHandle) = t; __STORE(self, t);
}
# if 0
@@ -4196,12 +4196,12 @@
* why - DAC
*/
{
- char null[DATALEN];
- int i;
- for (i = 0; i < DATALEN; i++) {
- null[i] = 127;
- }
- audioWrite(null, DATALEN);
+ char null[DATALEN];
+ int i;
+ for (i = 0; i < DATALEN; i++) {
+ null[i] = 127;
+ }
+ audioWrite(null, DATALEN);
}
# endif /* 0 */
ok = true;
@@ -4211,11 +4211,11 @@
#endif /* !SUPPORT_WIN32_DIRECTSOUND */
%}.
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.
! !
@@ -4225,25 +4225,25 @@
supportedAudioFormats
"return a collection of supported audio formats.
possibly returned symbols are:
- U8 unsigned 8bit samples
- S8 signed 8bit samples
- U16 unsigned 16bit samples in native format
- U16_LE unsigned 16bit big endian samples
- U16_BE unsigned 16bit big endian samples
- S16 signed 16bit little endian samples in native format
- S16_LE signed 16bit little endian samples
- S16_BE signed 16bit big endian samples
- S24 signed 24bit little endian samples in native format
- S24_LE signed 24bit little endian samples
- S24_BE signed 24bit big endian samples
- S32 signed 32bit little endian samples in native format
- S32_LE signed 32bit little endian samples
- S32_BE signed 32bit big endian samples
- F32 float samples
- MPEG audio mpeg encoded
- MU_LAW u-law encoded 8bit samples
- A_LAW a-law encoded 8bit samples
- IMA_ADPCM adpcm encoded
+ U8 unsigned 8bit samples
+ S8 signed 8bit samples
+ U16 unsigned 16bit samples in native format
+ U16_LE unsigned 16bit big endian samples
+ U16_BE unsigned 16bit big endian samples
+ S16 signed 16bit little endian samples in native format
+ S16_LE signed 16bit little endian samples
+ S16_BE signed 16bit big endian samples
+ S24 signed 24bit little endian samples in native format
+ S24_LE signed 24bit little endian samples
+ S24_BE signed 24bit big endian samples
+ S32 signed 32bit little endian samples in native format
+ S32_LE signed 32bit little endian samples
+ S32_BE signed 32bit big endian samples
+ F32 float samples
+ MPEG audio mpeg encoded
+ MU_LAW u-law encoded 8bit samples
+ A_LAW a-law encoded 8bit samples
+ IMA_ADPCM adpcm encoded
the set of returned symbols depends on the underlying sound hardware.
"
@@ -4289,7 +4289,7 @@
OBJ oWaveHandle;
if ((oWaveHandle = __INST(waveHandle)) == nil) {
- RETURN(0);
+ RETURN(0);
}
t_waveHandle = __WaveHandleVal(oWaveHandle);
@@ -4298,50 +4298,50 @@
buf = (short *)__InstPtr(anObject) + OHDR_SIZE + offs;
while (dataLen > 0) {
- if (free_list == NULL && total_buffers < MAXBUF) {
- /* Expand available buffer space */
- bp = (struct buf *)malloc(sizeof(struct buf));
- total_buffers++;
- } else {
- if (free_list == NULL) {
- /* We must wait for a free buffer */
- while (free_list == NULL) {
- WaitForSingleObject(free_buffer_event, INFINITE);
- }
- }
- EnterCriticalSection(&free_list_lock);
- bp = free_list;
- free_list = free_list->next;
- --free_buffers;
- LeaveCriticalSection(&free_list_lock);
- r = waveOutUnprepareHeader(t_waveHandle, &bp->hdr, sizeof(WAVEHDR));
- if (r != 0) {
- console_printf("waveOutUnprepareHeader\n");
- RETURN(self);
- }
- }
- len = min(dataLen, DATALEN);
- bp->hdr.lpData = (char *)bp->data;
- bp->hdr.dwBufferLength = len;
- bp->hdr.dwBytesRecorded = len;
- bp->hdr.dwUser = (INT)(bp);
- bp->hdr.dwFlags = 0;
- bp->hdr.dwLoops = 0;
- r = waveOutPrepareHeader(t_waveHandle, &bp->hdr, sizeof(WAVEHDR));
- if (r != 0) {
- console_printf("waveOutPrepareHeader\n");
- RETURN(self);
- }
- for (i = 0; i < len; i++) {
- bp->data[i] = buf[i];
- }
- r = waveOutWrite(t_waveHandle, &bp->hdr, sizeof(WAVEHDR));
- if (r != 0) {
- console_printf("waveOutWrite\n");
- RETURN(self);
- }
- buf += len;
- dataLen -= len;
+ if (free_list == NULL && total_buffers < MAXBUF) {
+ /* Expand available buffer space */
+ bp = (struct buf *)malloc(sizeof(struct buf));
+ total_buffers++;
+ } else {
+ if (free_list == NULL) {
+ /* We must wait for a free buffer */
+ while (free_list == NULL) {
+ WaitForSingleObject(free_buffer_event, INFINITE);
+ }
+ }
+ EnterCriticalSection(&free_list_lock);
+ bp = free_list;
+ free_list = free_list->next;
+ --free_buffers;
+ LeaveCriticalSection(&free_list_lock);
+ r = waveOutUnprepareHeader(t_waveHandle, &bp->hdr, sizeof(WAVEHDR));
+ if (r != 0) {
+ console_printf("waveOutUnprepareHeader\n");
+ RETURN(self);
+ }
+ }
+ len = min(dataLen, DATALEN);
+ bp->hdr.lpData = (char *)bp->data;
+ bp->hdr.dwBufferLength = len;
+ bp->hdr.dwBytesRecorded = len;
+ bp->hdr.dwUser = (INT)(bp);
+ bp->hdr.dwFlags = 0;
+ bp->hdr.dwLoops = 0;
+ r = waveOutPrepareHeader(t_waveHandle, &bp->hdr, sizeof(WAVEHDR));
+ if (r != 0) {
+ console_printf("waveOutPrepareHeader\n");
+ RETURN(self);
+ }
+ for (i = 0; i < len; i++) {
+ bp->data[i] = buf[i];
+ }
+ r = waveOutWrite(t_waveHandle, &bp->hdr, sizeof(WAVEHDR));
+ if (r != 0) {
+ console_printf("waveOutWrite\n");
+ RETURN(self);
+ }
+ buf += len;
+ dataLen -= len;
}
RETURN (count);
}