SoundStream.st
author Claus Gittinger <cg@exept.de>
Tue, 10 Feb 2015 21:46:46 +0100
changeset 3482 a78459c5bfaf
parent 3226 d439384d80bd
child 3622 33c345c6d1d9
permissions -rw-r--r--
class: SoundStream changed: #initialize
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4
1f66800df351 *** empty log message ***
claus
parents: 3
diff changeset
     1
"
1f66800df351 *** empty log message ***
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1993 by Claus Gittinger
45
claus
parents: 36
diff changeset
     3
	      All Rights Reserved
4
1f66800df351 *** empty log message ***
claus
parents: 3
diff changeset
     4
1f66800df351 *** empty log message ***
claus
parents: 3
diff changeset
     5
 This software is furnished under a license and may be used
1f66800df351 *** empty log message ***
claus
parents: 3
diff changeset
     6
 only in accordance with the terms of that license and with the
1f66800df351 *** empty log message ***
claus
parents: 3
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
1f66800df351 *** empty log message ***
claus
parents: 3
diff changeset
     8
 be provided or otherwise made available to, or used by, any
1f66800df351 *** empty log message ***
claus
parents: 3
diff changeset
     9
 other person.  No title to or ownership of the software is
1f66800df351 *** empty log message ***
claus
parents: 3
diff changeset
    10
 hereby transferred.
1f66800df351 *** empty log message ***
claus
parents: 3
diff changeset
    11
"
918
c93d55269f9d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 861
diff changeset
    12
"{ Package: 'stx:libbasic2' }"
c93d55269f9d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 861
diff changeset
    13
3482
a78459c5bfaf class: SoundStream
Claus Gittinger <cg@exept.de>
parents: 3226
diff changeset
    14
"{ NameSpace: Smalltalk }"
a78459c5bfaf class: SoundStream
Claus Gittinger <cg@exept.de>
parents: 3226
diff changeset
    15
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
    16
FileStream subclass:#SoundStream
2418
4ea40741b2b5 Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
    17
	instanceVariableNames:'sampleRate numberOfChannels bitsPerSample audioFormat handle1
4ea40741b2b5 Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
    18
		handle2 bufferOffset bufferSize'
595
fcff6c911d4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
    19
	classVariableNames:'UnsupportedOperationSignal'
259
6d36f3ac42a2 documentation
Claus Gittinger <cg@exept.de>
parents: 217
diff changeset
    20
	poolDictionaries:''
6d36f3ac42a2 documentation
Claus Gittinger <cg@exept.de>
parents: 217
diff changeset
    21
	category:'Streams-External'
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
    22
!
1cf8d1747859 Initial revision
claus
parents:
diff changeset
    23
121
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
    24
!SoundStream primitiveDefinitions!
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
    25
%{
725
c18d8d084a17 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
    26
2818
94d67df5c00d compilable with tcc
Claus Gittinger <cg@exept.de>
parents: 2418
diff changeset
    27
#include "stxOSDefs.h"
94d67df5c00d compilable with tcc
Claus Gittinger <cg@exept.de>
parents: 2418
diff changeset
    28
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    29
#ifdef WIN32
2818
94d67df5c00d compilable with tcc
Claus Gittinger <cg@exept.de>
parents: 2418
diff changeset
    30
# ifndef NO_SOUND
94d67df5c00d compilable with tcc
Claus Gittinger <cg@exept.de>
parents: 2418
diff changeset
    31
#  define xxxUSE_WIN32_DIRECTSOUND
94d67df5c00d compilable with tcc
Claus Gittinger <cg@exept.de>
parents: 2418
diff changeset
    32
#  define USE_WIN32_WAVESOUND
94d67df5c00d compilable with tcc
Claus Gittinger <cg@exept.de>
parents: 2418
diff changeset
    33
# endif
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    34
#endif
725
c18d8d084a17 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
    35
121
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
    36
#ifdef IRIS
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
    37
# ifndef IRIX5
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    38
#  define USE_IRIS_AUDIO
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    39
# endif
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    40
#endif
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    41
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    42
#ifndef USE_IRIS_AUDIO
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    43
# ifndef USE_ALSA_AUDIO
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    44
#  ifdef LINUX
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    45
#   define USE_DEV_AUDIO
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    46
#  endif
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    47
# endif
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    48
#endif
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    49
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    50
#ifdef USE_IRIS_AUDIO
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    51
# define IRIS_AUDIO
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    52
# include <audio.h>
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    53
# define __ALportVal(o)  (ALport)(__externalAddressVal(o))
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    54
# define alPort handle1
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    55
#endif
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    56
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    57
#ifdef USE_ALSA_AUDIO
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    58
# ifdef LINUX
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    59
#  define ALSA_AUDIO
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    60
#  include <alsa/asoundlib.h>
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    61
#  define MAX_NR_OF_CHANNELS 8
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    62
#  define DEBUG_SOUND
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    63
#  define readHandle handle1
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    64
#  define writeHandle handle2
121
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
    65
# endif
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
    66
#endif
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
    67
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    68
#ifdef USE_DEV_AUDIO
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    69
# ifdef LINUX
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    70
#  include <stdio.h>
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    71
#  include <sys/soundcard.h>
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    72
#  define DEV_AUDIO_DEFAULT_FREQ (8000)
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    73
#  define DEV_AUDIO_DEFAULT_BUFFERSIZE (16384)
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    74
#  define DEV_AUDIO
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    75
# endif
592
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
    76
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    77
# ifdef FREEBSD
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    78
#  include <stdio.h>
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    79
#  include <sys/time.h>
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    80
#  include <sys/ioctl.h>
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    81
#  include <machine/pcaudioio.h>
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    82
#  define DEV_AUDIO_DEFAULT_FREQ (8000)
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    83
#  define DEV_AUDIO_DEFAULT_BUFFERSIZE (16384)
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    84
#  define DEV_AUDIO
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    85
# endif
594
0d62900b49c8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    86
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    87
# if defined(sunos) || defined(solaris)
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    88
#  include <stdio.h>
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    89
#  ifdef solaris
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    90
#   include <sys/audioio.h>
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    91
#  else
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    92
#   include <sun/audioio.h>
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    93
#  endif
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    94
#  define DEV_AUDIO_DEFAULT_FREQ (8000)
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    95
#  define DEV_AUDIO_DEFAULT_BUFFERSIZE (16384)
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    96
#  define DEV_AUDIO
724
2b22b88165ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
    97
# endif
2b22b88165ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
    98
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
    99
# if defined(hpux)
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   100
#  include <stdio.h>
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   101
#  include <sys/ioctl.h>
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   102
#  include <sys/inode.h>
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   103
#  include <sys/audio.h>
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   104
#  include <sys/time.h>
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   105
#  include <unistd.h>
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   106
#  define DEV_AUDIO_DEFAULT_FREQ (22050)
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   107
#  define DEV_AUDIO_DEFAULT_BUFFERSIZE (16384)
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   108
#  define DEV_AUDIO
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   109
# endif
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   110
#endif /* USE_DEV_AUDIO */
594
0d62900b49c8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   111
924
4d262097b161 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 923
diff changeset
   112
#ifndef WIN32
4d262097b161 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 923
diff changeset
   113
# ifndef O_WRONLY
4d262097b161 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 923
diff changeset
   114
#  include <sys/fcntl.h>
4d262097b161 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 923
diff changeset
   115
# endif
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   116
# include <errno.h>
924
4d262097b161 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 923
diff changeset
   117
#endif
720
967fad20a8f1 newest stdio uses __new
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   118
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   119
#ifdef WIN32
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   120
# define _WIN32
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   121
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   122
# undef INT
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   123
# undef Array
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   124
# undef Number
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   125
# undef Method
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   126
# undef Point
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   127
# undef Rectangle
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   128
# undef Block
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   129
# undef String
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   130
# undef Message
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   131
# undef Object
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   132
# undef Context
753
5a323ea4ba4d *** empty log message ***
ps
parents: 752
diff changeset
   133
# undef Time
5a323ea4ba4d *** empty log message ***
ps
parents: 752
diff changeset
   134
# undef Date
1853
b9c4a09bfc6a Fix name clashes with windows header files
Stefan Vogel <sv@exept.de>
parents: 1839
diff changeset
   135
# undef Process
b9c4a09bfc6a Fix name clashes with windows header files
Stefan Vogel <sv@exept.de>
parents: 1839
diff changeset
   136
# undef Processor
861
af186a6b5139 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   137
# undef Set
af186a6b5139 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   138
# undef Signal
af186a6b5139 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   139
# undef Delay
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   140
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   141
/* # include <stdarg.h> /* */
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   142
# include <stdio.h> /* */
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   143
# include <windows.h>
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   144
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   145
# ifdef USE_WIN32_DIRECTSOUND
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   146
#  define WIN32_DIRECTSOUND
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   147
#  define CINTERFACE
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   148
#  include "dsound.h"
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   149
#  define __DirectSoundVal(o) (LPDIRECTSOUND)(__externalAddressVal(o))
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   150
#  define __DSBufferVal(o)    (LPDIRECTSOUNDBUFFER)(__externalAddressVal(o))
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   151
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   152
#  define RT_BUFFER_SIZE 4096
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   153
#  define NBUFS          4
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   154
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   155
#  define pDirectSound handle1
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   156
#  define pDSBuffer    handle2
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   157
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   158
# else /* USE WAVE... */
2818
94d67df5c00d compilable with tcc
Claus Gittinger <cg@exept.de>
parents: 2418
diff changeset
   159
#  ifdef USE_WIN32_WAVESOUND
94d67df5c00d compilable with tcc
Claus Gittinger <cg@exept.de>
parents: 2418
diff changeset
   160
#   define WIN32_WAVE
94d67df5c00d compilable with tcc
Claus Gittinger <cg@exept.de>
parents: 2418
diff changeset
   161
#   define __WaveHandleVal(o)    (HWAVEOUT)(__externalAddressVal(o))
94d67df5c00d compilable with tcc
Claus Gittinger <cg@exept.de>
parents: 2418
diff changeset
   162
#   define MAXBUF      10        /* Maximum number of buffers */
94d67df5c00d compilable with tcc
Claus Gittinger <cg@exept.de>
parents: 2418
diff changeset
   163
#   define DATALEN     2048      /* Size of wave data buffer */
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   164
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   165
struct buf {
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   166
    WAVEHDR hdr;                /* Wave data header */
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
   167
    char data[DATALEN];         /* Actual wave data */
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   168
    struct buf *next;           /* Next buffer in free list */
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   169
};
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   170
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
   171
static struct buf *free_list = NULL;      /* List of available buffers */
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
   172
static CRITICAL_SECTION free_list_lock;
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
   173
static int free_buffers = 0;             /* Number of buffers in free list */
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
   174
static int total_buffers = 0;            /* Total number of buffers allocated */
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
   175
static HANDLE free_buffer_event;         /* Automatic-reset event triggered whenever */
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   176
2818
94d67df5c00d compilable with tcc
Claus Gittinger <cg@exept.de>
parents: 2418
diff changeset
   177
#   define waveHandle handle1
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   178
2818
94d67df5c00d compilable with tcc
Claus Gittinger <cg@exept.de>
parents: 2418
diff changeset
   179
#  endif /* USE_WIN32_WAVESOUND */
94d67df5c00d compilable with tcc
Claus Gittinger <cg@exept.de>
parents: 2418
diff changeset
   180
# endif /* USE_WIN32_DIRECTSOUND */
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   181
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   182
# ifdef __DEF_Array
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   183
#  define Array __DEF_Array
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   184
# endif
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   185
# ifdef __DEF_Number
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   186
#  define Number __DEF_Number
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   187
# endif
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   188
# ifdef __DEF_Method
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   189
#  define Method __DEF_Method
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   190
# endif
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   191
# ifdef __DEF_Point
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   192
#  define Point __DEF_Point
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   193
# endif
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   194
# ifdef __DEF_Block
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   195
#  define Block __DEF_Block
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   196
# endif
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   197
# ifdef __DEF_String
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   198
#  define String __DEF_String
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   199
# endif
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   200
# ifdef __DEF_Message
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   201
#  define Message __DEF_Message
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   202
# endif
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   203
# ifdef __DEF_Object
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   204
#  define Object __DEF_Object
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   205
# endif
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   206
# ifdef __DEF_Context
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   207
#  define Context __DEF_Context
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   208
# endif
753
5a323ea4ba4d *** empty log message ***
ps
parents: 752
diff changeset
   209
# ifdef __DEF_Time
5a323ea4ba4d *** empty log message ***
ps
parents: 752
diff changeset
   210
#  define Time __DEF_Time
5a323ea4ba4d *** empty log message ***
ps
parents: 752
diff changeset
   211
# endif
5a323ea4ba4d *** empty log message ***
ps
parents: 752
diff changeset
   212
# ifdef __DEF_Date
5a323ea4ba4d *** empty log message ***
ps
parents: 752
diff changeset
   213
#  define Date __DEF_Date
5a323ea4ba4d *** empty log message ***
ps
parents: 752
diff changeset
   214
# endif
1853
b9c4a09bfc6a Fix name clashes with windows header files
Stefan Vogel <sv@exept.de>
parents: 1839
diff changeset
   215
#ifdef __DEF_Process
b9c4a09bfc6a Fix name clashes with windows header files
Stefan Vogel <sv@exept.de>
parents: 1839
diff changeset
   216
# define Process __DEF_Process
b9c4a09bfc6a Fix name clashes with windows header files
Stefan Vogel <sv@exept.de>
parents: 1839
diff changeset
   217
#endif
b9c4a09bfc6a Fix name clashes with windows header files
Stefan Vogel <sv@exept.de>
parents: 1839
diff changeset
   218
#ifdef __DEF_Processor
b9c4a09bfc6a Fix name clashes with windows header files
Stefan Vogel <sv@exept.de>
parents: 1839
diff changeset
   219
# define Processor __DEF_Processor
b9c4a09bfc6a Fix name clashes with windows header files
Stefan Vogel <sv@exept.de>
parents: 1839
diff changeset
   220
#endif
861
af186a6b5139 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   221
#ifdef __DEF_Set
af186a6b5139 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   222
# define Set __DEF_Set
af186a6b5139 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   223
#endif
af186a6b5139 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   224
#ifdef __DEF_Signal
af186a6b5139 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   225
# define Signal __DEF_Signal
af186a6b5139 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   226
#endif
af186a6b5139 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   227
#ifdef __DEF_Delay
af186a6b5139 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   228
# define Delay __DEF_Delay
af186a6b5139 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 788
diff changeset
   229
#endif
753
5a323ea4ba4d *** empty log message ***
ps
parents: 752
diff changeset
   230
3000
Claus Gittinger <cg@exept.de>
parents: 2833
diff changeset
   231
# define INT  STX_INT
Claus Gittinger <cg@exept.de>
parents: 2833
diff changeset
   232
# define UINT STX_UINT
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   233
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   234
#endif /* WIN32 */
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   235
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   236
#ifdef DEBUG_SOUND
1839
c10cd58ec334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1583
diff changeset
   237
# define DPRINTF(x) console_printf x
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   238
#else
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   239
# define DPRINTF(x) /* as nothing */
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   240
#endif
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   241
121
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   242
%}
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   243
! !
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   244
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   245
!SoundStream primitiveFunctions!
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   246
%{
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   247
#ifdef WIN32_WAVE
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   248
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   249
static void CALLBACK
3000
Claus Gittinger <cg@exept.de>
parents: 2833
diff changeset
   250
waveCallBack(HWAVE waveHandle, UINT msg, DWORD_PTR inst, DWORD_PTR p1, DWORD_PTR p2)
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   251
{
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   252
    if (msg == MM_WOM_DONE) {
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   253
	struct buf *bp = (struct buf *)p1;
3000
Claus Gittinger <cg@exept.de>
parents: 2833
diff changeset
   254
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   255
	EnterCriticalSection(&free_list_lock);
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   256
	bp->next = free_list;
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   257
	free_list = bp;
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   258
	free_buffers++;
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   259
	SetEvent(free_buffer_event);
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   260
	LeaveCriticalSection(&free_list_lock);
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   261
    }
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   262
}
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   263
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   264
#endif /* WIN32_WAVE */
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   265
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   266
%}
788
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
   267
! !
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
   268
28
350f8e9493a4 *** empty log message ***
claus
parents: 15
diff changeset
   269
!SoundStream class methodsFor:'documentation'!
350f8e9493a4 *** empty log message ***
claus
parents: 15
diff changeset
   270
31
e223f3cf2995 *** empty log message ***
claus
parents: 28
diff changeset
   271
copyright
e223f3cf2995 *** empty log message ***
claus
parents: 28
diff changeset
   272
"
e223f3cf2995 *** empty log message ***
claus
parents: 28
diff changeset
   273
 COPYRIGHT (c) 1993 by Claus Gittinger
45
claus
parents: 36
diff changeset
   274
	      All Rights Reserved
31
e223f3cf2995 *** empty log message ***
claus
parents: 28
diff changeset
   275
e223f3cf2995 *** empty log message ***
claus
parents: 28
diff changeset
   276
 This software is furnished under a license and may be used
e223f3cf2995 *** empty log message ***
claus
parents: 28
diff changeset
   277
 only in accordance with the terms of that license and with the
e223f3cf2995 *** empty log message ***
claus
parents: 28
diff changeset
   278
 inclusion of the above copyright notice.   This software may not
e223f3cf2995 *** empty log message ***
claus
parents: 28
diff changeset
   279
 be provided or otherwise made available to, or used by, any
e223f3cf2995 *** empty log message ***
claus
parents: 28
diff changeset
   280
 other person.  No title to or ownership of the software is
e223f3cf2995 *** empty log message ***
claus
parents: 28
diff changeset
   281
 hereby transferred.
e223f3cf2995 *** empty log message ***
claus
parents: 28
diff changeset
   282
"
e223f3cf2995 *** empty log message ***
claus
parents: 28
diff changeset
   283
!
e223f3cf2995 *** empty log message ***
claus
parents: 28
diff changeset
   284
28
350f8e9493a4 *** empty log message ***
claus
parents: 15
diff changeset
   285
documentation
350f8e9493a4 *** empty log message ***
claus
parents: 15
diff changeset
   286
"
592
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   287
    Preliminary (unfinished) interface to audio device.
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   288
    Currently works with LINUXs or SUNs /dev/audio driver and
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   289
    IRIX (indy).
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   290
    On iris, the default setup is for 8 bit mono
28
350f8e9493a4 *** empty log message ***
claus
parents: 15
diff changeset
   291
    so I can play the standard sound files I have here.
350f8e9493a4 *** empty log message ***
claus
parents: 15
diff changeset
   292
    It needs much more work, for stereo, different sampling rates etc.
350f8e9493a4 *** empty log message ***
claus
parents: 15
diff changeset
   293
592
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   294
    This is an experimental class - its interface & implementation
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   295
    may change in the future.
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   296
259
6d36f3ac42a2 documentation
Claus Gittinger <cg@exept.de>
parents: 217
diff changeset
   297
    [author:]
277
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   298
	Claus Gittinger
28
350f8e9493a4 *** empty log message ***
claus
parents: 15
diff changeset
   299
"
152
89d93f115cb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 121
diff changeset
   300
! !
45
claus
parents: 36
diff changeset
   301
595
fcff6c911d4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   302
!SoundStream class methodsFor:'initialization'!
fcff6c911d4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   303
fcff6c911d4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   304
initialize
fcff6c911d4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   305
    UnsupportedOperationSignal isNil ifTrue:[
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   306
	UnsupportedOperationSignal := StreamError newSignalMayProceed:true.
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   307
	UnsupportedOperationSignal nameClass:self message:#unsupportedOperationSignal.
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   308
	UnsupportedOperationSignal notifierString:'unsupported operation'.
595
fcff6c911d4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   309
    ]
fcff6c911d4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   310
! !
fcff6c911d4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   311
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   312
!SoundStream class methodsFor:'instance creation'!
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   313
932
1c9375cf97fc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   314
readWrite
1c9375cf97fc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   315
    "create and return a new soundStream for readWrite (i.e. filtering)"
1c9375cf97fc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   316
1c9375cf97fc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   317
    |newStream|
1c9375cf97fc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   318
    newStream := (self basicNew) initialize.
1c9375cf97fc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   319
    newStream openForReadWrite isNil ifTrue:[^nil].
1c9375cf97fc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   320
    ^ newStream
1c9375cf97fc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   321
1c9375cf97fc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   322
    "SoundStream readWrite"
1c9375cf97fc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   323
!
1c9375cf97fc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
   324
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   325
reading
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   326
    "create and return a new soundStream for reading (i.e. recording)"
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   327
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   328
    |newStream|
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   329
    newStream := (self basicNew) initialize.
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   330
    newStream openForReading isNil ifTrue:[^nil].
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   331
    ^ newStream
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   332
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   333
    "SoundStream reading"
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   334
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   335
    "Modified: / 12.12.1997 / 16:51:56 / cg"
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   336
!
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   337
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   338
writing
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   339
    "create and return a new soundStream for writing (i.e. playback)"
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   340
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   341
    |newStream|
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   342
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   343
    newStream := (self basicNew) initialize.
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   344
    newStream openForWriting isNil ifTrue:[^nil].
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   345
    ^ newStream
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   346
121
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   347
    "
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   348
     SoundStream writing
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   349
    "
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   350
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   351
    "Created: / 17.11.1995 / 17:25:42 / cg"
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   352
    "Modified: / 12.12.1997 / 16:51:38 / cg"
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   353
!
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   354
714
ebeacc2e07bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   355
writing16Bit
ebeacc2e07bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   356
    "just an example, has never been tried (I also
ebeacc2e07bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   357
     have no samples for this ... leave it as an exercise)"
ebeacc2e07bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   358
ebeacc2e07bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   359
    |newStream|
ebeacc2e07bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   360
ebeacc2e07bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   361
    newStream := (self basicNew) initialize.
ebeacc2e07bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   362
    newStream bitsPerSample:16.
ebeacc2e07bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   363
    newStream openForWriting isNil ifTrue:[^nil].
ebeacc2e07bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   364
    ^ newStream
ebeacc2e07bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   365
ebeacc2e07bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   366
    "SoundStream writing16Bit"
ebeacc2e07bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   367
ebeacc2e07bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   368
    "Modified: / 12.12.1997 / 16:51:49 / cg"
ebeacc2e07bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   369
    "Created: / 21.12.1998 / 00:02:17 / cg"
ebeacc2e07bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   370
!
ebeacc2e07bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   371
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   372
writing16BitStereo
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   373
    "just an example, has never been tried (I also
592
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   374
     have no samples for this ... leave it as an exercise)"
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   375
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   376
    |newStream|
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   377
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   378
    OperatingSystem getCPUType ~= 'irix' ifTrue:[
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   379
	self error:'unsupported audio mode'.
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   380
    ].
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   381
    newStream := (self basicNew) initialize.
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   382
    newStream bitsPerSample:16.
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   383
    newStream numberOfChannels:2.
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   384
    newStream openForWriting isNil ifTrue:[^nil].
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   385
    ^ newStream
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   386
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   387
    "SoundStream writing16BitStereo"
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   388
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   389
    "Modified: / 12.12.1997 / 16:51:49 / cg"
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   390
! !
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   391
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   392
!SoundStream class methodsFor:'Signal constants'!
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   393
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   394
unsupportedOperationSignal
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   395
    ^ UnsupportedOperationSignal
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   396
! !
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   397
592
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   398
!SoundStream class methodsFor:'conversion helpers'!
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   399
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   400
linear16ToUlaw:a16bitSignedValue
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   401
    "given a 16it signed value, encode into uLaw byte"
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   402
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   403
    |absVal sign exp mantissa byte|
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   404
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   405
%{
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   406
    /*
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   407
     * so heavily used when playing sounds ...
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   408
     * made it a primitive.
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   409
     */
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   410
    if (__isSmallInteger(a16bitSignedValue)) {
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   411
	int __sign = 0;
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   412
	int __absVal = __intVal(a16bitSignedValue);
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   413
	int __exp, __mantissa, __byte;
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   414
	static char __uLawExp[] =
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   415
		    {
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   416
			0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   417
			5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   418
			6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   419
			6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   420
			7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   421
			7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   422
			7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   423
			7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   424
		    };
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   425
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   426
	if (__absVal < 0) {
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   427
	    if (__absVal <= -32256) {
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   428
		RETURN (__MKSMALLINT(0));
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   429
	    }
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   430
	    __absVal = -__absVal;
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   431
	    __sign = 0x80;
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   432
	} else {
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   433
	    if (__absVal >= 32256) {
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   434
		RETURN (__MKSMALLINT(128));
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   435
	    }
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   436
	}
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   437
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   438
	__exp = __uLawExp[__absVal >> 8];
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   439
	__mantissa = (__absVal >> (__exp+3)) & 0xF;
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   440
	__byte = ~(__sign | (__exp<<4) | __mantissa) & 0xFF;
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   441
	RETURN (__MKSMALLINT(__byte));
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   442
    }
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   443
%}.
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   444
    "/
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   445
    "/ fallback for non-integral argument
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   446
    "/
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   447
    a16bitSignedValue isInteger ifFalse:[
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   448
	^ self uLawToLinear16:a16bitSignedValue asInteger
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   449
    ].
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   450
    ^ 0
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   451
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   452
    "
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   453
     SoundStream uLawToLinear16:(SoundStream linear16ToUlaw:0)
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   454
     SoundStream uLawToLinear16:(SoundStream linear16ToUlaw:32256)
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   455
     SoundStream uLawToLinear16:(SoundStream linear16ToUlaw:-32256)
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   456
     SoundStream uLawToLinear16:(SoundStream linear16ToUlaw:32767)
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   457
     SoundStream uLawToLinear16:(SoundStream linear16ToUlaw:-32767)
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   458
     SoundStream uLawToLinear16:(SoundStream linear16ToUlaw:100)
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   459
     SoundStream uLawToLinear16:(SoundStream linear16ToUlaw:-100)
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   460
     SoundStream uLawToLinear16:(SoundStream linear16ToUlaw:104)
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   461
     SoundStream uLawToLinear16:(SoundStream linear16ToUlaw:-104)
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   462
    "
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   463
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   464
    "Modified: / 9.12.1997 / 16:46:24 / cg"
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   465
!
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   466
592
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   467
uLawToLinear16:uLawValue
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   468
    "given a uLaw byte, return the decoded signed 16bit value.
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   469
     Currently unused - but will be"
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   470
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   471
    ^ #(
45
claus
parents: 36
diff changeset
   472
	"0  "     -32256
claus
parents: 36
diff changeset
   473
	"1  "     -31228
claus
parents: 36
diff changeset
   474
	"2  "     -30200
claus
parents: 36
diff changeset
   475
	"3  "     -29172
claus
parents: 36
diff changeset
   476
	"4  "     -28143
claus
parents: 36
diff changeset
   477
	"5  "     -27115
claus
parents: 36
diff changeset
   478
	"6  "     -26087
claus
parents: 36
diff changeset
   479
	"7  "     -25059
claus
parents: 36
diff changeset
   480
	"8  "     -24031
claus
parents: 36
diff changeset
   481
	"9  "     -23002
claus
parents: 36
diff changeset
   482
	"10 "     -21974
claus
parents: 36
diff changeset
   483
	"11 "     -20946
claus
parents: 36
diff changeset
   484
	"12 "     -19918
claus
parents: 36
diff changeset
   485
	"13 "     -18889
claus
parents: 36
diff changeset
   486
	"14 "     -17861
claus
parents: 36
diff changeset
   487
	"15 "     -16833
claus
parents: 36
diff changeset
   488
	"16 "     -16062
claus
parents: 36
diff changeset
   489
	"17 "     -15548
claus
parents: 36
diff changeset
   490
	"18 "     -15033
claus
parents: 36
diff changeset
   491
	"19 "     -14519
claus
parents: 36
diff changeset
   492
	"20 "     -14005
claus
parents: 36
diff changeset
   493
	"21 "     -13491
claus
parents: 36
diff changeset
   494
	"22 "     -12977
claus
parents: 36
diff changeset
   495
	"23 "     -12463
claus
parents: 36
diff changeset
   496
	"24 "     -11949
claus
parents: 36
diff changeset
   497
	"25 "     -11435
claus
parents: 36
diff changeset
   498
	"26 "     -10920
claus
parents: 36
diff changeset
   499
	"27 "     -10406
claus
parents: 36
diff changeset
   500
	"28 "     -9892
claus
parents: 36
diff changeset
   501
	"29 "     -9378
claus
parents: 36
diff changeset
   502
	"30 "     -8864
claus
parents: 36
diff changeset
   503
	"31 "     -8350
claus
parents: 36
diff changeset
   504
	"32 "     -7964
claus
parents: 36
diff changeset
   505
	"33 "     -7707
claus
parents: 36
diff changeset
   506
	"34 "     -7450
claus
parents: 36
diff changeset
   507
	"35 "     -7193
claus
parents: 36
diff changeset
   508
	"36 "     -6936
claus
parents: 36
diff changeset
   509
	"37 "     -6679
claus
parents: 36
diff changeset
   510
	"38 "     -6422
claus
parents: 36
diff changeset
   511
	"39 "     -6165
claus
parents: 36
diff changeset
   512
	"40 "     -5908
claus
parents: 36
diff changeset
   513
	"41 "     -5651
claus
parents: 36
diff changeset
   514
	"42 "     -5394
claus
parents: 36
diff changeset
   515
	"43 "     -5137
claus
parents: 36
diff changeset
   516
	"44 "     -4880
claus
parents: 36
diff changeset
   517
	"45 "     -4623
claus
parents: 36
diff changeset
   518
	"46 "     -4365
claus
parents: 36
diff changeset
   519
	"47 "     -4108
claus
parents: 36
diff changeset
   520
	"48 "     -3916
claus
parents: 36
diff changeset
   521
	"49 "     -3787
claus
parents: 36
diff changeset
   522
	"50 "     -3659
claus
parents: 36
diff changeset
   523
	"51 "     -3530
claus
parents: 36
diff changeset
   524
	"52 "     -3402
claus
parents: 36
diff changeset
   525
	"53 "     -3273
claus
parents: 36
diff changeset
   526
	"54 "     -3144
claus
parents: 36
diff changeset
   527
	"55 "     -3016
claus
parents: 36
diff changeset
   528
	"56 "     -2887
claus
parents: 36
diff changeset
   529
	"57 "     -2759
claus
parents: 36
diff changeset
   530
	"58 "     -2630
claus
parents: 36
diff changeset
   531
	"59 "     -2502
claus
parents: 36
diff changeset
   532
	"60 "     -2373
claus
parents: 36
diff changeset
   533
	"61 "     -2245
claus
parents: 36
diff changeset
   534
	"62 "     -2116
claus
parents: 36
diff changeset
   535
	"63 "     -1988
claus
parents: 36
diff changeset
   536
	"64 "     -1891
claus
parents: 36
diff changeset
   537
	"65 "     -1827
claus
parents: 36
diff changeset
   538
	"66 "     -1763
claus
parents: 36
diff changeset
   539
	"67 "     -1698
claus
parents: 36
diff changeset
   540
	"68 "     -1634
claus
parents: 36
diff changeset
   541
	"69 "     -1570
claus
parents: 36
diff changeset
   542
	"70 "     -1506
claus
parents: 36
diff changeset
   543
	"71 "     -1441
claus
parents: 36
diff changeset
   544
	"72 "     -1377
claus
parents: 36
diff changeset
   545
	"73 "     -1313
claus
parents: 36
diff changeset
   546
	"74 "     -1249
claus
parents: 36
diff changeset
   547
	"75 "     -1184
claus
parents: 36
diff changeset
   548
	"76 "     -1120
claus
parents: 36
diff changeset
   549
	"77 "     -1056
claus
parents: 36
diff changeset
   550
	"78 "     -992
claus
parents: 36
diff changeset
   551
	"79 "     -927
claus
parents: 36
diff changeset
   552
	"80 "     -879
claus
parents: 36
diff changeset
   553
	"81 "     -847
claus
parents: 36
diff changeset
   554
	"82 "     -815
claus
parents: 36
diff changeset
   555
	"83 "     -783
claus
parents: 36
diff changeset
   556
	"84 "     -751
claus
parents: 36
diff changeset
   557
	"85 "     -718
claus
parents: 36
diff changeset
   558
	"86 "     -686
claus
parents: 36
diff changeset
   559
	"87 "     -654
claus
parents: 36
diff changeset
   560
	"88 "     -622
claus
parents: 36
diff changeset
   561
	"89 "     -590
claus
parents: 36
diff changeset
   562
	"90 "     -558
claus
parents: 36
diff changeset
   563
	"91 "     -526
claus
parents: 36
diff changeset
   564
	"92 "     -494
claus
parents: 36
diff changeset
   565
	"93 "     -461
claus
parents: 36
diff changeset
   566
	"94 "     -429
claus
parents: 36
diff changeset
   567
	"95 "     -397
claus
parents: 36
diff changeset
   568
	"96 "     -373
claus
parents: 36
diff changeset
   569
	"97 "     -357
claus
parents: 36
diff changeset
   570
	"98 "     -341
claus
parents: 36
diff changeset
   571
	"99 "     -325
claus
parents: 36
diff changeset
   572
	"100"     -309
claus
parents: 36
diff changeset
   573
	"101"     -293
claus
parents: 36
diff changeset
   574
	"102"     -277
claus
parents: 36
diff changeset
   575
	"103"     -261
claus
parents: 36
diff changeset
   576
	"104"     -245
claus
parents: 36
diff changeset
   577
	"105"     -228
claus
parents: 36
diff changeset
   578
	"106"     -212
claus
parents: 36
diff changeset
   579
	"107"     -196
claus
parents: 36
diff changeset
   580
	"108"     -180
claus
parents: 36
diff changeset
   581
	"109"     -164
claus
parents: 36
diff changeset
   582
	"110"     -148
claus
parents: 36
diff changeset
   583
	"111"     -132
claus
parents: 36
diff changeset
   584
	"112"     -120
claus
parents: 36
diff changeset
   585
	"113"     -112
claus
parents: 36
diff changeset
   586
	"114"     -104
claus
parents: 36
diff changeset
   587
	"115"     -96
claus
parents: 36
diff changeset
   588
	"116"     -88
claus
parents: 36
diff changeset
   589
	"117"     -80
claus
parents: 36
diff changeset
   590
	"118"     -72
claus
parents: 36
diff changeset
   591
	"119"     -64
claus
parents: 36
diff changeset
   592
	"120"     -56
claus
parents: 36
diff changeset
   593
	"121"     -48
claus
parents: 36
diff changeset
   594
	"122"     -40
claus
parents: 36
diff changeset
   595
	"123"     -32
claus
parents: 36
diff changeset
   596
	"124"     -24
claus
parents: 36
diff changeset
   597
	"125"     -16
claus
parents: 36
diff changeset
   598
	"126"     -8
claus
parents: 36
diff changeset
   599
	"127"     0
claus
parents: 36
diff changeset
   600
	"128"     32256
claus
parents: 36
diff changeset
   601
	"129"     31228
claus
parents: 36
diff changeset
   602
	"130"     30200
claus
parents: 36
diff changeset
   603
	"131"     29172
claus
parents: 36
diff changeset
   604
	"132"     28143
claus
parents: 36
diff changeset
   605
	"133"     27115
claus
parents: 36
diff changeset
   606
	"134"     26087
claus
parents: 36
diff changeset
   607
	"135"     25059
claus
parents: 36
diff changeset
   608
	"136"     24031
claus
parents: 36
diff changeset
   609
	"137"     23002
claus
parents: 36
diff changeset
   610
	"138"     21974
claus
parents: 36
diff changeset
   611
	"139"     20946
claus
parents: 36
diff changeset
   612
	"140"     19918
claus
parents: 36
diff changeset
   613
	"141"     18889
claus
parents: 36
diff changeset
   614
	"142"     17861
claus
parents: 36
diff changeset
   615
	"143"     16833
claus
parents: 36
diff changeset
   616
	"144"     16062
claus
parents: 36
diff changeset
   617
	"145"     15548
claus
parents: 36
diff changeset
   618
	"146"     15033
claus
parents: 36
diff changeset
   619
	"147"     14519
claus
parents: 36
diff changeset
   620
	"148"     14005
claus
parents: 36
diff changeset
   621
	"149"     13491
claus
parents: 36
diff changeset
   622
	"150"     12977
claus
parents: 36
diff changeset
   623
	"151"     12463
claus
parents: 36
diff changeset
   624
	"152"     11949
claus
parents: 36
diff changeset
   625
	"153"     11435
claus
parents: 36
diff changeset
   626
	"154"     10920
claus
parents: 36
diff changeset
   627
	"155"     10406
claus
parents: 36
diff changeset
   628
	"156"     9892
claus
parents: 36
diff changeset
   629
	"157"     9378
claus
parents: 36
diff changeset
   630
	"158"     8864
claus
parents: 36
diff changeset
   631
	"159"     8350
claus
parents: 36
diff changeset
   632
	"160"     7964
claus
parents: 36
diff changeset
   633
	"161"     7707
claus
parents: 36
diff changeset
   634
	"162"     7450
claus
parents: 36
diff changeset
   635
	"163"     7193
claus
parents: 36
diff changeset
   636
	"164"     6936
claus
parents: 36
diff changeset
   637
	"165"     6679
claus
parents: 36
diff changeset
   638
	"166"     6422
claus
parents: 36
diff changeset
   639
	"167"     6165
claus
parents: 36
diff changeset
   640
	"168"     5908
claus
parents: 36
diff changeset
   641
	"169"     5651
claus
parents: 36
diff changeset
   642
	"170"     5394
claus
parents: 36
diff changeset
   643
	"171"     5137
claus
parents: 36
diff changeset
   644
	"172"     4880
claus
parents: 36
diff changeset
   645
	"173"     4623
claus
parents: 36
diff changeset
   646
	"174"     4365
claus
parents: 36
diff changeset
   647
	"175"     4108
claus
parents: 36
diff changeset
   648
	"176"     3916
claus
parents: 36
diff changeset
   649
	"177"     3787
claus
parents: 36
diff changeset
   650
	"178"     3659
claus
parents: 36
diff changeset
   651
	"179"     3530
claus
parents: 36
diff changeset
   652
	"180"     3402
claus
parents: 36
diff changeset
   653
	"181"     3273
claus
parents: 36
diff changeset
   654
	"182"     3144
claus
parents: 36
diff changeset
   655
	"183"     3016
claus
parents: 36
diff changeset
   656
	"184"     2887
claus
parents: 36
diff changeset
   657
	"185"     2759
claus
parents: 36
diff changeset
   658
	"186"     2630
claus
parents: 36
diff changeset
   659
	"187"     2502
claus
parents: 36
diff changeset
   660
	"188"     2373
claus
parents: 36
diff changeset
   661
	"189"     2245
claus
parents: 36
diff changeset
   662
	"190"     2116
claus
parents: 36
diff changeset
   663
	"191"     1988
claus
parents: 36
diff changeset
   664
	"192"     1891
claus
parents: 36
diff changeset
   665
	"193"     1827
claus
parents: 36
diff changeset
   666
	"194"     1763
claus
parents: 36
diff changeset
   667
	"195"     1698
claus
parents: 36
diff changeset
   668
	"196"     1634
claus
parents: 36
diff changeset
   669
	"197"     1570
claus
parents: 36
diff changeset
   670
	"198"     1506
claus
parents: 36
diff changeset
   671
	"199"     1441
claus
parents: 36
diff changeset
   672
	"200"     1377
claus
parents: 36
diff changeset
   673
	"201"     1313
claus
parents: 36
diff changeset
   674
	"202"     1249
claus
parents: 36
diff changeset
   675
	"203"     1184
claus
parents: 36
diff changeset
   676
	"204"     1120
claus
parents: 36
diff changeset
   677
	"205"     1056
claus
parents: 36
diff changeset
   678
	"206"     992
claus
parents: 36
diff changeset
   679
	"207"     927
claus
parents: 36
diff changeset
   680
	"208"     879
claus
parents: 36
diff changeset
   681
	"209"     847
claus
parents: 36
diff changeset
   682
	"210"     815
claus
parents: 36
diff changeset
   683
	"211"     783
claus
parents: 36
diff changeset
   684
	"212"     751
claus
parents: 36
diff changeset
   685
	"213"     718
claus
parents: 36
diff changeset
   686
	"214"     686
claus
parents: 36
diff changeset
   687
	"215"     654
claus
parents: 36
diff changeset
   688
	"216"     622
claus
parents: 36
diff changeset
   689
	"217"     590
claus
parents: 36
diff changeset
   690
	"218"     558
claus
parents: 36
diff changeset
   691
	"219"     526
claus
parents: 36
diff changeset
   692
	"220"     494
claus
parents: 36
diff changeset
   693
	"221"     461
claus
parents: 36
diff changeset
   694
	"222"     429
claus
parents: 36
diff changeset
   695
	"223"     397
claus
parents: 36
diff changeset
   696
	"224"     373
claus
parents: 36
diff changeset
   697
	"225"     357
claus
parents: 36
diff changeset
   698
	"226"     341
claus
parents: 36
diff changeset
   699
	"227"     325
claus
parents: 36
diff changeset
   700
	"228"     309
claus
parents: 36
diff changeset
   701
	"229"     293
claus
parents: 36
diff changeset
   702
	"230"     277
claus
parents: 36
diff changeset
   703
	"231"     261
claus
parents: 36
diff changeset
   704
	"232"     245
claus
parents: 36
diff changeset
   705
	"233"     228
claus
parents: 36
diff changeset
   706
	"234"     212
claus
parents: 36
diff changeset
   707
	"235"     196
claus
parents: 36
diff changeset
   708
	"236"     180
claus
parents: 36
diff changeset
   709
	"237"     164
claus
parents: 36
diff changeset
   710
	"238"     148
claus
parents: 36
diff changeset
   711
	"239"     132
claus
parents: 36
diff changeset
   712
	"240"     120
claus
parents: 36
diff changeset
   713
	"241"     112
claus
parents: 36
diff changeset
   714
	"242"     104
claus
parents: 36
diff changeset
   715
	"243"     96
claus
parents: 36
diff changeset
   716
	"244"     88
claus
parents: 36
diff changeset
   717
	"245"     80
claus
parents: 36
diff changeset
   718
	"246"     72
claus
parents: 36
diff changeset
   719
	"247"     64
claus
parents: 36
diff changeset
   720
	"248"     56
claus
parents: 36
diff changeset
   721
	"249"     48
claus
parents: 36
diff changeset
   722
	"250"     40
claus
parents: 36
diff changeset
   723
	"251"     32
claus
parents: 36
diff changeset
   724
	"252"     24
claus
parents: 36
diff changeset
   725
	"253"     16
claus
parents: 36
diff changeset
   726
	"254"     8
claus
parents: 36
diff changeset
   727
	"255"     0
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   728
    ) at:(uLawValue + 1)
592
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   729
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   730
    "Modified: / 9.12.1997 / 16:34:17 / cg"
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   731
! !
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   732
121
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   733
!SoundStream class methodsFor:'default values'!
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   734
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   735
defaultAudioFormat
2822
371789d0fe49 changed:
Stefan Vogel <sv@exept.de>
parents: 2818
diff changeset
   736
    OperatingSystem isMSWINDOWSlike ifTrue:[
3000
Claus Gittinger <cg@exept.de>
parents: 2833
diff changeset
   737
	^ #S16
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   738
    ].
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   739
    ^ #U8
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   740
!
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   741
121
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   742
defaultBitsPerSample
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   743
    "minimum, supported by all audio systems"
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   744
2822
371789d0fe49 changed:
Stefan Vogel <sv@exept.de>
parents: 2818
diff changeset
   745
    OperatingSystem isMSWINDOWSlike ifTrue:[
3000
Claus Gittinger <cg@exept.de>
parents: 2833
diff changeset
   746
	^ 16
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   747
    ].
121
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   748
    ^ 8
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   749
!
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   750
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   751
defaultNumberOfChannels
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   752
    "minimum, supported by all audio systems"
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   753
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   754
    ^ 1
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   755
!
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   756
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   757
defaultSampleRate
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   758
    "minimum, supported by all audio systems"
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   759
724
2b22b88165ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   760
%{
2b22b88165ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   761
#ifdef DEV_AUDIO
2b22b88165ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   762
    RETURN (__MKSMALLINT(DEV_AUDIO_DEFAULT_FREQ));
2b22b88165ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   763
#endif
2b22b88165ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   764
%}.
2b22b88165ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   765
121
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   766
    ^ 8000
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   767
! !
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   768
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   769
!SoundStream class methodsFor:'playing'!
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   770
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   771
playSoundFile:aFilename
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   772
    "play a soundFile"
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   773
121
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   774
    |inStream soundStream count totalCount buffer startTime playTime delayedTime waitTime|
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   775
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   776
    inStream := aFilename asFilename readStream.
1154
6158d4545b71 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 1151
diff changeset
   777
    inStream isNil ifTrue:[self error:'cannot open'].
121
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   778
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   779
    soundStream := self writing.
1154
6158d4545b71 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 1151
diff changeset
   780
    soundStream isNil ifTrue:[self error:'cannot open sound device'].
121
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   781
1432
077bf1bfc8c4 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
   782
    startTime := Timestamp now.
121
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   783
    totalCount := 0.
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   784
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   785
    buffer := ByteArray new:4096.
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   786
    [(count := inStream nextBytesInto:buffer) > 0] whileTrue:[
3226
d439384d80bd class: SoundStream
Claus Gittinger <cg@exept.de>
parents: 3216
diff changeset
   787
        totalCount := totalCount + count.
d439384d80bd class: SoundStream
Claus Gittinger <cg@exept.de>
parents: 3216
diff changeset
   788
        soundStream nextPutBytes:count from:buffer.
121
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   789
    ].
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   790
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   791
    inStream close.
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   792
    soundStream commit.
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   793
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   794
    "/
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   795
    "/ at least the linux audio driver behaves funny, if we close too early ...
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   796
    "/
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   797
    playTime := totalCount / soundStream sampleRate.
3226
d439384d80bd class: SoundStream
Claus Gittinger <cg@exept.de>
parents: 3216
diff changeset
   798
    delayedTime := Timestamp now secondDeltaFrom: startTime.
121
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   799
    waitTime := playTime - delayedTime + 0.1.
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   800
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   801
    (Delay forSeconds:waitTime) wait.
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   802
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   803
    soundStream close.
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   804
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   805
    "
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   806
     SoundStream playSoundFile:'/usr/local/lib/sounds/laugh.snd'
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   807
     SoundStream playSoundFile:'/usr/local/lib/sounds/spacemusic.snd'
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   808
    "
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   809
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   810
    "Created: 17.11.1995 / 17:25:30 / cg"
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   811
    "Modified: 17.11.1995 / 17:45:40 / cg"
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   812
! !
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   813
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   814
!SoundStream methodsFor:'catching invalid methods'!
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   815
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   816
pathName:filename
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   817
    "catch pathname access - its fixed here"
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   818
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   819
    self shouldNotImplement
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   820
!
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   821
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   822
pathName:filename in:aDirectory
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   823
    "catch pathname access - its fixed here"
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   824
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   825
    self shouldNotImplement
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   826
! !
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   827
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   828
!SoundStream methodsFor:'mode setting'!
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   829
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   830
bitsPerSample
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   831
    "return the number of bits per sample - usually 8"
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   832
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   833
    ^ bitsPerSample
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   834
!
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   835
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   836
bitsPerSample:aNumber
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   837
    "set the number of bits per sample"
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   838
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   839
    bitsPerSample := aNumber
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   840
!
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   841
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   842
numberOfChannels
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   843
    "return the number of channels (1 or 2; usually 1)"
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   844
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   845
    ^ numberOfChannels
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   846
!
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   847
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   848
numberOfChannels:aNumber
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   849
    "set the number of channels"
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   850
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   851
    numberOfChannels := aNumber
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   852
!
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   853
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   854
sampleRate
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   855
    "return the sample rate"
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   856
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   857
    ^ sampleRate
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   858
!
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   859
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   860
sampleRate:aNumber
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   861
    "set the sample rate in hertz - on some
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   862
     devices, this is a nop"
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   863
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   864
    self setSampleRate:aNumber.
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   865
! !
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   866
592
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   867
!SoundStream methodsFor:'private'!
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   868
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   869
dumpSettings
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   870
    "debugging interface - dump the current settings"
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   871
919
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
   872
    |fd blockSize speed channels stereo format|
592
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   873
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   874
    fd := self fileDescriptor.
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   875
    fd isNil ifTrue:[
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   876
	self errorNotOpen.
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   877
	^ nil
592
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   878
    ].
921
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   879
    audioFormat == #S16 ifTrue:[
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   880
	UninterpretedBytes isBigEndian ifTrue:[
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   881
	    audioFormat := #S16_BE
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   882
	] ifFalse:[
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   883
	    audioFormat := #S16_LE
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   884
	]
921
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   885
    ].
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   886
    audioFormat == #U16 ifTrue:[
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   887
	UninterpretedBytes isBigEndian ifTrue:[
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   888
	    audioFormat := #U16_BE
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   889
	] ifFalse:[
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   890
	    audioFormat := #U16_LE
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   891
	]
921
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   892
    ].
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   893
592
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   894
%{
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   895
    int f = __intVal(fd);
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   896
    int __blockSize = -1;
921
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   897
    int __speed = -1;
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   898
    int __channels = __intVal(__INST(numberOfChannels));
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   899
    int __stereo = __channels > 1;
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   900
    int __format = -1;
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   901
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   902
    if (0) {
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   903
    }
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   904
    else if (__INST(audioFormat) == @symbol(MU_LAW)) {
921
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   905
#  ifdef AFMT_MU_LAW
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   906
	__format = AFMT_MU_LAW;
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   907
#  endif
921
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   908
    }
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   909
    else if (__INST(audioFormat) == @symbol(A_LAW)) {
921
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   910
#  ifdef AFMT_A_LAW
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   911
	__format = AFMT_A_LAW;
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   912
#  endif
921
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   913
    }
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   914
    else if (__INST(audioFormat) == @symbol(IMA_ADPCM)) {
921
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   915
#  ifdef AFMT_IMA_ADPCM
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   916
	__format = AFMT_IMA_ADPCM;
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   917
#  endif
921
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   918
    }
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   919
    else if (__INST(audioFormat) == @symbol(U8)) {
921
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   920
#  ifdef AFMT_U8
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   921
	__format = AFMT_U8;
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   922
#  endif
921
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   923
    }
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   924
    else if (__INST(audioFormat) == @symbol(S16_LE)) {
921
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   925
#  ifdef AFMT_S16_LE
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   926
	__format = AFMT_S16_LE;
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   927
#  endif
921
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   928
    }
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   929
    else if (__INST(audioFormat) == @symbol(S16_BE)) {
921
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   930
#  ifdef AFMT_S16_BE
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   931
	__format = AFMT_S16_BE;
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   932
#  endif
921
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   933
    }
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   934
    else if (__INST(audioFormat) == @symbol(S8)) {
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   935
#  ifdef AFMT_S8
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   936
	__format = AFMT_S8;
921
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   937
#  endif
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   938
    }
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   939
    else if (__INST(audioFormat) == @symbol(U16_LE)) {
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   940
#  ifdef AFMT_U16_LE
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   941
	__format = AFMT_U16_LE;
921
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   942
#  endif
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   943
    }
921
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   944
    else if (__INST(audioFormat) == @symbol(U16_BE)) {
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   945
#  ifdef AFMT_U16_BE
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   946
	__format = AFMT_U16_BE;
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   947
#  endif
921
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   948
    }
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
   949
    else if (__INST(audioFormat) == @symbol(MPEG)) {
921
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   950
#  ifdef AFMT_MPEG
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   951
	__format = AFMT_MPEG;
921
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   952
#  endif
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   953
    }
592
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   954
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   955
#if defined(DEV_AUDIO)
921
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   956
    channels = nil;
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   957
    blockSize = nil;
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   958
    stereo = nil;
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   959
    speed = nil;
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   960
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   961
# if defined(SNDCTL_DSP_GETBLKSIZE)
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   962
    if (ioctl(f, SNDCTL_DSP_GETBLKSIZE, &__blockSize) >= 0) {
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   963
	blockSize = __MKSMALLINT(__blockSize);
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   964
    }
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   965
# endif
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   966
# if defined(SNDCTL_DSP_CHANNELS)
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   967
    if (ioctl(f, SNDCTL_DSP_CHANNELS, &__channels) >= 0) {
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   968
	channels = __MKSMALLINT(__channels);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   969
	stereo = __MKSMALLINT(__channels > 1);
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   970
    }
921
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   971
# else
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   972
#  if defined(SNDCTL_DSP_STEREO)
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   973
    if (ioctl(f, SNDCTL_DSP_STEREO, &__stereo) >= 0) {
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   974
	stereo = __MKSMALLINT(__stereo);
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   975
    }
921
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   976
#  endif
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   977
# endif
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   978
# if defined(SNDCTL_DSP_SPEED)
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   979
    if (ioctl(f, SNDCTL_DSP_SPEED, &__speed) >= 0) {
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   980
	speed = __MKSMALLINT(__speed);
919
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
   981
    }
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
   982
# endif
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
   983
# if defined(SNDCTL_DSP_GETFMT)
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
   984
    if (ioctl(f, SNDCTL_DSP_GETFMT, &__format) >= 0) {
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   985
	format = __MKSMALLINT(__format);
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
   986
    }
919
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
   987
# else
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
   988
#  if defined(SNDCTL_DSP_SETFMT) && defined(AFMT_QUERY)
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
   989
    __format = AFMT_QUERY;
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
   990
    if (ioctl(f, SNDCTL_DSP_SETFMT, &__format) >= 0) {
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   991
	switch (__format) {
919
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
   992
#ifdef AFMT_MU_LAW
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   993
	    case AFMT_MU_LAW:
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   994
		format = @symbol(MU_LAW);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   995
		break;
919
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
   996
#endif
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
   997
#ifdef AFMT_A_LAW
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   998
	    case AFMT_A_LAW:
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   999
		format = @symbol(A_LAW);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1000
		break;
919
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1001
#endif
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1002
#ifdef AFMT_U8
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1003
	    case AFMT_U8:
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1004
		format = @symbol(U8);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1005
		break;
919
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1006
#endif
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1007
#ifdef AFMT_S8
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1008
	    case AFMT_S8:
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1009
		format = @symbol(S8);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1010
		break;
919
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1011
#endif
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1012
#ifdef AFMT_S16_LE
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1013
	    case AFMT_S16_LE:
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1014
		format = @symbol(S16_LE);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1015
		break;
919
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1016
#endif
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1017
#ifdef AFMT_S16_BE
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1018
	    case AFMT_S16_BE:
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1019
		format = @symbol(S16_BE);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1020
		break;
919
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1021
#endif
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1022
#ifdef AFMT_U16_LE
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1023
	    case AFMT_U16_LE:
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1024
		format = @symbol(U16_LE);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1025
		break;
919
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1026
#endif
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1027
#ifdef AFMT_U16_BE
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1028
	    case AFMT_U16_BE:
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1029
		format = @symbol(U16_BE);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1030
		break;
919
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1031
#endif
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1032
#ifdef AFMT_MPEG
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1033
	    case AFMT_MPEG:
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1034
		format = @symbol(MPEG);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1035
		break;
919
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1036
#endif
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1037
	    default:
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1038
		format = nil;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1039
	}
919
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1040
    }
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1041
#  endif
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1042
# endif
594
0d62900b49c8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1043
#endif /* DEV_AUDIO */
592
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1044
%}.
919
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1045
    format notNil ifTrue:[
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1046
	Transcript show:'format: '; showCR:format
919
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1047
    ].
592
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1048
    blockSize notNil ifTrue:[
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1049
	Transcript show:'blockSize: '; showCR:blockSize
592
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1050
    ].
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1051
    speed notNil ifTrue:[
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1052
	Transcript show:'speed: '; showCR:speed
592
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1053
    ].
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1054
    channels notNil ifTrue:[
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1055
	Transcript show:'channels: '; showCR:channels
592
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1056
    ].
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1057
    stereo notNil ifTrue:[
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1058
	Transcript show:'stereo: '; showCR:stereo
592
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1059
    ].
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1060
920
1c8a18a7a7cf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 919
diff changeset
  1061
    Transcript show:'supported audioFormats: '; showCR:(self supportedAudioFormats).
592
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1062
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1063
    "
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1064
     self writing dumpSettings; close
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1065
    "
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1066
!
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1067
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1068
initialize
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1069
    "initialize for least common mode"
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1070
3156
edeed9ecae5b initialize methods
Stefan Vogel <sv@exept.de>
parents: 3154
diff changeset
  1071
    super initialize.
3482
a78459c5bfaf class: SoundStream
Claus Gittinger <cg@exept.de>
parents: 3226
diff changeset
  1072
    "/ transparent
a78459c5bfaf class: SoundStream
Claus Gittinger <cg@exept.de>
parents: 3226
diff changeset
  1073
    eolMode := nil.
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1074
    buffered := false.
1269
17546758fc7a buffered:falsem to NonPositionableExternalStreams is already set.
Stefan Vogel <sv@exept.de>
parents: 1154
diff changeset
  1075
    binary := true.
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1076
    bitsPerSample := self class defaultBitsPerSample.
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1077
    audioFormat := self class defaultAudioFormat.
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1078
    numberOfChannels := self class defaultNumberOfChannels.
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1079
    sampleRate := self class defaultSampleRate.
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1080
    pathName := nil.
595
fcff6c911d4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1081
2822
371789d0fe49 changed:
Stefan Vogel <sv@exept.de>
parents: 2818
diff changeset
  1082
    OperatingSystem isUNIXlike ifTrue:[
3154
23ac6f3e69b6 Initialize in instance initialize method insted in #new
Stefan Vogel <sv@exept.de>
parents: 3000
diff changeset
  1083
        '/dev/audio' asFilename exists ifTrue:[
23ac6f3e69b6 Initialize in instance initialize method insted in #new
Stefan Vogel <sv@exept.de>
parents: 3000
diff changeset
  1084
            "/
23ac6f3e69b6 Initialize in instance initialize method insted in #new
Stefan Vogel <sv@exept.de>
parents: 3000
diff changeset
  1085
            "/ sunos or linux
23ac6f3e69b6 Initialize in instance initialize method insted in #new
Stefan Vogel <sv@exept.de>
parents: 3000
diff changeset
  1086
            "/
23ac6f3e69b6 Initialize in instance initialize method insted in #new
Stefan Vogel <sv@exept.de>
parents: 3000
diff changeset
  1087
            pathName := '/dev/audio'.
23ac6f3e69b6 Initialize in instance initialize method insted in #new
Stefan Vogel <sv@exept.de>
parents: 3000
diff changeset
  1088
        ].
595
fcff6c911d4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1089
    ].
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1090
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1091
    "Created: 17.11.1995 / 17:28:14 / cg"
592
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1092
!
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1093
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1094
resetSoundCard
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1095
    "debugging interface - reset the soundCard"
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1096
592
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1097
    |fd|
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1098
2321
6f4cc7b644db filePointer -> handle migration
Claus Gittinger <cg@exept.de>
parents: 1853
diff changeset
  1099
    handle notNil ifTrue:[
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1100
	fd := self fileDescriptor.
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1101
	fd isNil ifTrue:[
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1102
	self errorNotOpen.
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1103
	    ^ nil
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1104
	]
592
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1105
    ].
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1106
%{
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1107
    int f = __intVal(fd);
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1108
    int __dummy;
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1109
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1110
#if defined(DEV_AUDIO)
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1111
    if (__isSmallInteger(fd)) {
614
565ea4308322 make it compilable on elder linux's
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
  1112
# if defined(SNDCTL_DSP_RESET)
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1113
	if (ioctl(f, SNDCTL_DSP_RESET, &__dummy) >= 0) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1114
	    RETURN (self);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1115
	}
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1116
# endif
592
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1117
    }
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1118
#endif /* DEV_AUDIO */
592
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1119
%}.
595
fcff6c911d4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1120
    ^ UnsupportedOperationSignal raise
592
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1121
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1122
    "
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1123
     self writing resetSoundCard; dumpSettings; close
592
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1124
    "
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1125
!
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1126
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1127
setAudioFormat:aSymbol
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1128
    "set the format of the audio data as specified by aSymbol.
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1129
     Returns true if sucessfull - may fail with some formats on many sound devices."
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1130
592
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1131
    |fd|
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1132
2321
6f4cc7b644db filePointer -> handle migration
Claus Gittinger <cg@exept.de>
parents: 1853
diff changeset
  1133
    handle notNil ifTrue:[
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1134
	fd := self fileDescriptor.
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1135
	fd isNil ifTrue:[
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1136
	    self errorNotOpen.
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1137
	    ^ nil
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1138
	]
592
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1139
    ].
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1140
%{
597
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  1141
    OBJ sym = aSymbol;
592
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1142
724
2b22b88165ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1143
    if (__INST(audioFormat) == sym) {
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1144
	RETURN (self);
724
2b22b88165ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1145
    }
2b22b88165ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1146
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1147
#if defined(DEV_AUDIO)
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1148
    if (__isSmallInteger(fd)) {
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1149
	int f = __intVal(fd);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1150
	int __fmt = 0, __fmtWant;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1151
	union {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1152
	    unsigned short us;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1153
	    unsigned char ub[2];
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1154
	} u;
923
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1155
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1156
	if (__isSymbol(sym)) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1157
	    if (sym == @symbol(U16)) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1158
		u.us = 0x1234;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1159
		if (u.ub[0] == 0x34) {
597
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  1160
/* printf("U16_LE\n"); */
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1161
		    sym = @symbol(U16_LE);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1162
		} else {
597
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  1163
/* printf("U16_BE\n"); */
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1164
		    sym = @symbol(U16_BE);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1165
		}
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1166
	    } else if (sym == @symbol(S16)) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1167
		u.us = 0x1234;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1168
		if (u.ub[0] == 0x34) {
597
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  1169
/* printf("S16_LE\n"); */
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1170
		   sym = @symbol(S16_LE);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1171
		} else {
597
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  1172
/* printf("S16_BE\n"); */
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1173
		   sym = @symbol(S16_BE);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1174
		}
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1175
	    }
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1176
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1177
	    if (0) {
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1178
# ifdef AFMT_MU_LAW
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1179
	    } else if (sym == @symbol(MU_LAW)) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1180
		__fmt = AFMT_MU_LAW;
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1181
# endif
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1182
# ifdef AFMT_A_LAW
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1183
	    } else if (sym == @symbol(A_LAW)) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1184
		__fmt = AFMT_A_LAW;
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1185
# endif
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1186
# ifdef AFMT_IMA_ADPCM
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1187
	    } else if (sym == @symbol(IMA_ADPCM)) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1188
		__fmt = AFMT_IMA_ADPCM;
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1189
# endif
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1190
# ifdef AFMT_U8
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1191
	    } else if (sym == @symbol(U8)) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1192
		__fmt = AFMT_U8;
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1193
# endif
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1194
# ifdef AFMT_S8
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1195
	    } else if (sym == @symbol(S8)) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1196
		__fmt = AFMT_S8;
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1197
# endif
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1198
# ifdef AFMT_U16_LE
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1199
	    } else if (sym == @symbol(U16_LE)) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1200
		__fmt = AFMT_U16_LE;
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1201
# endif
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1202
# ifdef AFMT_U16_BE
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1203
	    } else if (sym == @symbol(U16_BE)) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1204
		__fmt = AFMT_U16_BE;
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1205
# endif
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1206
# ifdef AFMT_S16_LE
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1207
	    } else if (sym == @symbol(S16_LE)) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1208
		__fmt = AFMT_S16_LE;
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1209
# endif
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1210
# ifdef AFMT_S16_BE
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1211
	    } else if (sym == @symbol(S16_BE)) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1212
		__fmt = AFMT_S16_BE;
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1213
# endif
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1214
# ifdef AFMT_MPEG
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1215
	    } else if (sym == @symbol(MPEG)) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1216
		__fmt = AFMT_MPEG;
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1217
# endif
724
2b22b88165ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1218
2b22b88165ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1219
# ifdef AUDIO_FORMAT_LINEAR16BIT
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1220
	    } else if (sym == @symbol(S16)) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1221
		__fmt = AUDIO_FORMAT_LINEAR16BIT;
724
2b22b88165ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1222
# endif
2b22b88165ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1223
# ifdef AUDIO_FORMAT_ULAW
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1224
	    } else if (sym == @symbol(MU_LAW)) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1225
		__fmt = AUDIO_FORMAT_ULAW;
724
2b22b88165ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1226
# endif
2b22b88165ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1227
# ifdef AUDIO_FORMAT_ALAW
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1228
	    } else if (sym == @symbol(A_LAW)) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1229
		__fmt = AUDIO_FORMAT_ALAW;
724
2b22b88165ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1230
# endif
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1231
	    } else {
1839
c10cd58ec334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1583
diff changeset
  1232
		console_fprintf(stderr, "bad format: %s\n", __stringVal(sym));
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1233
		goto bad;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1234
	    }
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1235
	}
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1236
724
2b22b88165ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1237
# ifdef SNDCTL_DSP_SETFMT
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1238
	__fmtWant = __fmt;
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1239
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1240
	if (ioctl(f, SNDCTL_DSP_SETFMT, &__fmt) >= 0) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1241
	    if (__fmt == __fmtWant) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1242
		__INST(audioFormat) = sym;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1243
		RETURN (self);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1244
	    } else {
1839
c10cd58ec334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1583
diff changeset
  1245
		/* console_fprintf(stderr, "want: %x; got: %x\n", __fmtWant, __fmt); */
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1246
	    }
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1247
	} else {
1839
c10cd58ec334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1583
diff changeset
  1248
		/* console_fprintf(stderr, "got err-ret from setFmp %x\n", __fmt); */
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1249
	}
919
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1250
# else
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1251
#  ifdef AUDIO_SET_DATA_FORMAT /* hpux */
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1252
	if (ioctl (f, AUDIO_SET_DATA_FORMAT, __fmt)) {
1839
c10cd58ec334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1583
diff changeset
  1253
	    /* console_fprintf(stderr, "got err-ret from AUDIO_SET_DATA_FORMAT\n"); */
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1254
	}
919
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1255
#  endif
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1256
# endif /* SNDCTL_DSP_SETFMT */
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1257
724
2b22b88165ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1258
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1259
bad: ;
592
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1260
    }
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1261
#endif /* DEV_AUDIO */
614
565ea4308322 make it compilable on elder linux's
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
  1262
592
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1263
%}.
597
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  1264
    ^ UnsupportedOperationSignal raise
592
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1265
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1266
    "
919
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1267
     self writing dumpSettings; close
592
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1268
     self writing setAudioFormat:#'MU_LAW'; close
597
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  1269
     self writing setAudioFormat:#'U8'; dumpSettings; close
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  1270
     self writing setAudioFormat:#'MPEG'; dumpSettings; close
592
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1271
    "
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1272
!
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1273
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1274
setChannels:nChannels
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1275
    "set the number of channels (1 -> mono; 2 -> stereo).
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1276
     Returns true if sucessfull - may fail with many sound devices."
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1277
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1278
    |fd|
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1279
2321
6f4cc7b644db filePointer -> handle migration
Claus Gittinger <cg@exept.de>
parents: 1853
diff changeset
  1280
    handle notNil ifTrue:[
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1281
	fd := self fileDescriptor.
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1282
	fd isNil ifTrue:[
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1283
	    self errorNotOpen.
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1284
	    ^ nil
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1285
	]
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1286
    ].
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1287
%{
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1288
724
2b22b88165ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1289
#if defined(DEV_AUDIO)
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1290
    if (__isSmallInteger(fd) && __isSmallInteger(nChannels)) {
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1291
	int f = __intVal(fd);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1292
	int __nCh = __intVal(nChannels);
920
1c8a18a7a7cf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 919
diff changeset
  1293
921
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
  1294
# if defined(SNDCTL_DSP_STEREO)
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1295
	if ((__nCh == 1) || (__nCh == 2)) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1296
	    int __stereo = (__nCh == 2) ? 1 : 0;
920
1c8a18a7a7cf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 919
diff changeset
  1297
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1298
	    if (ioctl(f, SNDCTL_DSP_STEREO, &__stereo) >= 0) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1299
		if (__stereo == 0) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1300
		    __INST(numberOfChannels) = __MKSMALLINT(1);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1301
		} else {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1302
		    __INST(numberOfChannels) = __MKSMALLINT(2);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1303
		}
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1304
		RETURN (self);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1305
	    }
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1306
	}
921
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
  1307
# else
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
  1308
#  if defined(SOUND_PCM_WRITE_CHANNELS)
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1309
	if (ioctl(f, SOUND_PCM_WRITE_CHANNELS, &__nCh) >= 0) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1310
	    __INST(numberOfChannels) = nChannels;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1311
	    RETURN (self);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1312
	}
920
1c8a18a7a7cf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 919
diff changeset
  1313
#  else
1c8a18a7a7cf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 919
diff changeset
  1314
#   ifdef AUDIO_SET_CHANNELS /* hpux */
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1315
	if (ioctl (f, AUDIO_SET_CHANNELS, __nCh)) {
1839
c10cd58ec334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1583
diff changeset
  1316
	    /* console_fprintf(stderr, "got err-ret from AUDIO_SET_CHANNELS\n"); */
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1317
	    __INST(numberOfChannels) = nChannels;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1318
	    RETURN (self);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1319
	}
920
1c8a18a7a7cf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 919
diff changeset
  1320
#   endif
921
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
  1321
#  endif
724
2b22b88165ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1322
# endif
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1323
    }
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1324
#endif
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1325
%}.
595
fcff6c911d4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1326
    ^ UnsupportedOperationSignal raise
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1327
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1328
    "
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1329
     self writing setChannels:2; dumpSettings; close
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1330
     self writing setChannels:2; setSampleRate:10000; dumpSettings; close
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1331
     self writing setChannels:2; setSampleRate:40000; dumpSettings; close
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1332
    "
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1333
!
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1334
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1335
setFragmentSize:blockSize
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1336
    "set the soundDrivers fragmentSize.
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1337
     Returns true if sucessfull - may fail with many sound devices."
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1338
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1339
    |fd|
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1340
2321
6f4cc7b644db filePointer -> handle migration
Claus Gittinger <cg@exept.de>
parents: 1853
diff changeset
  1341
    handle notNil ifTrue:[
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1342
	fd := self fileDescriptor.
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1343
	fd isNil ifTrue:[
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1344
	    self errorNotOpen.
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1345
	    ^ nil
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1346
	]
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1347
    ].
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1348
%{
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1349
    int f = __intVal(fd);
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1350
    int __blockSize = 0;
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1351
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1352
#if defined(DEV_AUDIO)
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1353
    if (__isSmallInteger(fd) && __isSmallInteger(blockSize)) {
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1354
	__blockSize = __intVal(blockSize);
724
2b22b88165ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1355
# if defined(SNDCTL_DSP_SETFRAGMENT)
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1356
	if (ioctl(f, SNDCTL_DSP_SETFRAGMENT, &__blockSize) >= 0) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1357
	    /* __INST(blockSize) = blockSize; */
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1358
	    RETURN (self);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1359
	}
724
2b22b88165ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1360
# endif
2b22b88165ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1361
# ifdef AUDIO_SET_CHANNELS /* hpux */
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1362
	if (ioctl (f, AUDIO_SET_TXBUFSIZE, __blockSize)) {
1839
c10cd58ec334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1583
diff changeset
  1363
	    /* console_fprintf(stderr, "got err-ret from AUDIO_SET_TXBUFSIZE\n"); */
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1364
	    /* __INST(blockSize) = blockSize; */
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1365
	    RETURN (self);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1366
	}
724
2b22b88165ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1367
# endif
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1368
    }
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1369
#endif
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1370
%}.
595
fcff6c911d4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1371
    ^ UnsupportedOperationSignal raise
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1372
!
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1373
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1374
setSampleRate:hz
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1375
    "set the sample rate.
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1376
     Returns true if sucessfull - may fail with many sound devices."
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1377
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1378
    |fd|
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1379
2321
6f4cc7b644db filePointer -> handle migration
Claus Gittinger <cg@exept.de>
parents: 1853
diff changeset
  1380
    handle notNil ifTrue:[
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1381
	fd := self fileDescriptor.
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1382
	fd isNil ifTrue:[
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1383
	    self errorNotOpen.
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1384
	    ^ nil
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1385
	]
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1386
    ].
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1387
%{
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1388
#if defined(DEV_AUDIO)
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1389
    if (__isSmallInteger(fd) && __isSmallInteger(hz)) {
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1390
	int f = __intVal(fd);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1391
	int __rate = __intVal(hz);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1392
	int __rateWant = __rate;
919
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1393
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1394
# if defined(SNDCTL_DSP_SPEED)
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1395
	if (ioctl(f, SNDCTL_DSP_SPEED, &__rate) >= 0) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1396
	    if (__rate != __rateWant) {
1839
c10cd58ec334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1583
diff changeset
  1397
		console_fprintf(stderr, "SoundStream [warning]: actual rate is %d\n", __rate);
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1398
		hz = __MKSMALLINT(__rate);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1399
	    }
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1400
	    __INST(sampleRate) = hz;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1401
	    RETURN (self);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1402
	}
919
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1403
# else
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1404
#  if defined(SOUND_PCM_WRITE_RATE)
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1405
	if (ioctl(f, SOUND_PCM_WRITE_RATE, &__rate) >= 0) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1406
	    if (__rate != __rateWant) {
1839
c10cd58ec334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1583
diff changeset
  1407
		console_fprintf(stderr, "SoundStream [warning]: actual rate is %d\n", __rate);
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1408
		hz = __MKSMALLINT(__rate);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1409
	    }
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1410
	    __INST(sampleRate) = hz;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1411
	    RETURN (self);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1412
	}
919
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1413
#  else
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1414
#   ifdef AUDIO_SET_SAMPLE_RATE /* hpux */
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1415
	if (ioctl (f, AUDIO_SET_SAMPLE_RATE, __rate)) {
1839
c10cd58ec334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1583
diff changeset
  1416
	    /* console_fprintf(stderr, "got err-ret from AUDIO_SET_SAMPLE_RATE\n"); */
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1417
	    __INST(sampleRate) = hz;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1418
	    RETURN (self);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1419
	}
919
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1420
#   endif
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1421
#  endif
724
2b22b88165ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1422
# endif
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1423
    }
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1424
#endif
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1425
%}.
595
fcff6c911d4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1426
    ^ UnsupportedOperationSignal raise
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1427
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1428
    "
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1429
     self writing setSampleRate:10000; dumpSettings; close
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1430
     self writing setSampleRate:1000; dumpSettings; close
919
5adc0bfa511d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
  1431
     self writing setSampleRate:8000; dumpSettings; close
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1432
    "
121
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
  1433
!
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
  1434
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1435
supportedAudioFormats
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1436
    "return a collection of supported audio formats.
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1437
     returned symbols are:
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1438
	U8        unsigned 8bit samples
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1439
	S8        signed 8bit samples
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1440
	MU_LAW    u-law encoded 8bit samples
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1441
	A_LAW     a-law encoded 8bit samples
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1442
	IMA_ADPCM adpcm encoded
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1443
	U16       unsigned 16bit samples
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1444
	U16_LE    unsigned 16bit big endian samples
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1445
	U16_BE    unsigned 16bit big endian samples
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1446
	S16       signed 16bit little endian samples
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1447
	S16_LE    signed 16bit little endian samples
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1448
	S16_BE    signed 16bit big endian samples
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1449
	MPEG      audio mpeg encoded
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1450
    "
121
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
  1451
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1452
    |fd audioFormatMask
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1453
     supportedFormats
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1454
     supports_MU_LAW supports_A_LAW
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1455
     supports_IMA_ADPCM supports_U8
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1456
     supports_S16_LE supports_S16_BE
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1457
     supports_S8 supports_U16_LE
713
85912db3ad19 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
  1458
     supports_U16_BE supports_MPEG|
121
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
  1459
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1460
    fd := self fileDescriptor.
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1461
    fd isNil ifTrue:[
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1462
	self errorNotOpen.
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1463
	^ nil
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1464
    ].
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1465
%{
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1466
    int f = __intVal(fd);
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1467
    int __audioFormatMask = 0;
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1468
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1469
#if defined(DEV_AUDIO)
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1470
    supports_MU_LAW = true;
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1471
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1472
# if defined(SNDCTL_DSP_GETFMTS)
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1473
    if (ioctl(f, SNDCTL_DSP_GETFMTS, &__audioFormatMask) >= 0) {
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1474
	audioFormatMask = __MKSMALLINT(__audioFormatMask);
121
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
  1475
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1476
#  ifdef AFMT_MU_LAW
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1477
	supports_MU_LAW = (__audioFormatMask & AFMT_MU_LAW) ? true : false;
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1478
#  endif
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1479
#  ifdef AFMT_A_LAW
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1480
	supports_A_LAW = (__audioFormatMask & AFMT_A_LAW) ? true : false;
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1481
#  endif
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1482
#  ifdef AFMT_IMA_ADPCM
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1483
	supports_IMA_ADPCM = (__audioFormatMask & AFMT_IMA_ADPCM) ? true : false;
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1484
#  endif
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1485
#  ifdef AFMT_U8
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1486
	supports_U8 = (__audioFormatMask & AFMT_U8) ? true : false;
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1487
#  endif
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1488
#  ifdef AFMT_S16_LE
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1489
	supports_S16_LE = (__audioFormatMask & AFMT_S16_LE) ? true : false;
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1490
#  endif
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1491
#  ifdef AFMT_S16_BE
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1492
	supports_S16_BE = (__audioFormatMask & AFMT_S16_BE) ? true : false;
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1493
#  endif
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1494
#  ifdef AFMT_S8
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1495
	supports_S8 = (__audioFormatMask & AFMT_S8) ? true : false;
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1496
#  endif
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1497
#  ifdef AFMT_U16_LE
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1498
	supports_U16_LE = (__audioFormatMask & AFMT_U16_LE) ? true : false;
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1499
#  endif
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1500
#  ifdef AFMT_U16_BE
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1501
	supports_U16_BE = (__audioFormatMask & AFMT_U16_BE) ? true : false;
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1502
#  endif
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1503
#  ifdef AFMT_MPEG
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1504
	supports_MPEG = (__audioFormatMask & AFMT_MPEG) ? true : false;
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1505
#  endif
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1506
    }
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1507
# endif
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  1508
724
2b22b88165ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1509
# ifdef hpux
2b22b88165ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1510
    supports_MU_LAW = true;
2b22b88165ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1511
    supports_A_LAW = true;
2b22b88165ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1512
    supports_S16_BE = true;
2b22b88165ec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1513
# endif
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1514
#endif /* DEV_AUDIO */
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  1515
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1516
#ifdef IRIS_AUDIO
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1517
    supports_U8 = true;
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1518
    supports_U16_BE = true;
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1519
#endif
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  1520
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1521
#ifdef WIN32
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1522
    supports_S16_LE = true;
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1523
#endif
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1524
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1525
%}.
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1526
    supportedFormats := IdentitySet new.
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1527
    supports_MU_LAW ifTrue:[
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1528
	supportedFormats add:#'MU_LAW'
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1529
    ].
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1530
    supports_A_LAW ifTrue:[
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1531
	supportedFormats add:#'A_LAW'
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1532
    ].
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1533
    supports_IMA_ADPCM ifTrue:[
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1534
	supportedFormats add:#'IMA_ADPCM'
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1535
    ].
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1536
    supports_S8 ifTrue:[
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1537
	supportedFormats add:#'S8'
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1538
    ].
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1539
    supports_U8 ifTrue:[
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1540
	supportedFormats add:#'U8'
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  1541
    ].
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1542
    supports_S16_LE ifTrue:[
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1543
	supportedFormats add:#'S16_LE'.
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1544
	UninterpretedBytes isBigEndian ifFalse:[
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1545
	    supportedFormats add:#'S16'.
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1546
	]
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1547
    ].
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1548
    supports_S16_BE ifTrue:[
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1549
	supportedFormats add:#'S16_BE'.
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1550
	UninterpretedBytes isBigEndian ifTrue:[
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1551
	    supportedFormats add:#'S16'.
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1552
	]
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1553
    ].
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1554
    supports_U16_LE ifTrue:[
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1555
	supportedFormats add:#'U16_LE'.
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1556
	UninterpretedBytes isBigEndian ifFalse:[
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1557
	    supportedFormats add:#'U16'.
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1558
	]
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1559
    ].
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1560
    supports_U16_BE ifTrue:[
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1561
	supportedFormats add:#'U16_BE'.
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1562
	UninterpretedBytes isBigEndian ifTrue:[
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1563
	    supportedFormats add:#'U16'.
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1564
	]
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1565
    ].
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1566
    supports_MPEG ifTrue:[
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1567
	supportedFormats add:#'MPEG'
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1568
    ].
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1569
    ^ supportedFormats.
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  1570
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1571
    "
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1572
     |s formats|
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  1573
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1574
     s := self writing.
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1575
     formats := s supportedAudioFormats.
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1576
     s close.
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1577
     formats
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1578
    "
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  1579
! !
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  1580
1474
1ad407692b0b Protect #closeFile.
Stefan Vogel <sv@exept.de>
parents: 1446
diff changeset
  1581
!SoundStream protectedMethodsFor:'redefined'!
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  1582
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1583
closeFile
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1584
    "a stream has been collected - close the file"
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1585
594
0d62900b49c8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1586
%{
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1587
#ifdef IRIS_AUDIO
595
fcff6c911d4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1588
    OBJ port;
fcff6c911d4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1589
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1590
    if ((port = __INST(alPort)) != nil) {
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1591
	__INST(alPort) = nil;
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1592
	ALcloseport(__ALportVal(port));
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1593
    }
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1594
    RETURN (self);
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1595
#endif /* IRIS_AUDIO */
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1596
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1597
#ifdef WIN32_DIRECTSOUND
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1598
    OBJ oDirectSound, oDSBuffer;
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1599
    LPDIRECTSOUND       t_pDirectSound;
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1600
    LPDIRECTSOUNDBUFFER t_pDSBuffer;
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1601
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1602
    if ((oDSBuffer = __INST(pDSBuffer)) != nil) {
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1603
	__INST(pDSBuffer) = nil;
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1604
	t_pDSBuffer = __DSBufferVal(oDSBuffer);
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1605
	if (t_pDSBuffer) {
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1606
	    IDirectSoundBuffer_Stop(t_pDSBuffer);
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1607
	    IDirectSoundBuffer_Release(t_pDSBuffer);
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1608
	}
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1609
    }
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1610
    if ((oDirectSound = __INST(pDirectSound)) != nil) {
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1611
	__INST(pDirectSound) = nil;
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1612
	t_pDirectSound = __DirectSoundVal(oDirectSound);
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1613
	if (t_pDirectSound) {
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1614
	    IDirectSound_Release(t_pDirectSound);
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1615
	}
595
fcff6c911d4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1616
    }
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1617
    RETURN (self);
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1618
#endif /* WIN32_DIRECTSOUND */
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1619
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1620
#ifdef WIN32_WAVE
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  1621
    struct buf *bp, *next;
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  1622
    int r;
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  1623
    HWAVEOUT t_waveHandle;
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  1624
    OBJ oWaveHandle;
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  1625
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  1626
    if ((oWaveHandle = __INST(waveHandle)) != nil) {
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  1627
	t_waveHandle = __WaveHandleVal(oWaveHandle);
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  1628
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1629
# ifdef NO_WAIT_IN_CLOSE
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  1630
	/* Force cancellation of any pending buffers */
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  1631
	(void)waveOutReset(t_waveHandle);
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1632
# endif
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  1633
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  1634
	/* Wait until all pending buffers have been freed */
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  1635
	while (free_buffers < total_buffers) {
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  1636
	    WaitForSingleObject(free_buffer_event, INFINITE);
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  1637
	}
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  1638
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1639
# ifndef NO_WAIT_IN_CLOSE
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1640
	/* Force cancellation of any pending buffers */
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1641
	(void)waveOutReset(t_waveHandle);
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1642
# endif
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1643
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  1644
	/* Close the device */
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  1645
	if ((r = waveOutClose(t_waveHandle)) != 0) {
1839
c10cd58ec334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1583
diff changeset
  1646
	    console_printf("waveOutClose\n");
922
2439a81a0530 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
  1647
	    RETURN(self);
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  1648
	}
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  1649
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1650
	EnterCriticalSection(&free_list_lock);
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1651
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  1652
	/* Free allocated buffers */
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  1653
	for (bp = free_list; bp != NULL; bp = next) {
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  1654
	    next = bp->next;
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  1655
	    (void)free(bp);
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  1656
	}
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1657
	free_list = NULL;
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1658
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1659
	LeaveCriticalSection(&free_list_lock);
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  1660
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  1661
	__INST(waveHandle) = nil;
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  1662
    }
595
fcff6c911d4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1663
    RETURN (self);
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1664
# endif /* WIN32_WAVE */
595
fcff6c911d4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1665
594
0d62900b49c8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1666
#if defined(DEV_AUDIO)
0d62900b49c8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1667
    OBJ fp;
0d62900b49c8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1668
    int fd;
0d62900b49c8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1669
    FILE *f;
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1670
2321
6f4cc7b644db filePointer -> handle migration
Claus Gittinger <cg@exept.de>
parents: 1853
diff changeset
  1671
    if ((fp = __INST(handle)) != nil) {
594
0d62900b49c8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1672
	f = __FILEVal(fp);
2321
6f4cc7b644db filePointer -> handle migration
Claus Gittinger <cg@exept.de>
parents: 1853
diff changeset
  1673
	__INST(handle) = nil;
594
0d62900b49c8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1674
# ifdef LINUX
0d62900b49c8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1675
	sigsetmask(~0);
0d62900b49c8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1676
# endif
0d62900b49c8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1677
	if (__INST(buffered) == true) {
0d62900b49c8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1678
	    fflush(f);
0d62900b49c8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1679
	    fclose(f);
0d62900b49c8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1680
	} else {
0d62900b49c8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1681
	    fd = fileno(f);
0d62900b49c8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1682
	    close(fd);
0d62900b49c8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1683
	    fclose(f);
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1684
	}
594
0d62900b49c8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1685
# ifdef LINUX
0d62900b49c8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1686
	sigsetmask(0);
0d62900b49c8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1687
# endif
0d62900b49c8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1688
    }
595
fcff6c911d4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1689
    RETURN (self);
594
0d62900b49c8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1690
#endif /* DEV_AUDIO */
595
fcff6c911d4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1691
%}.
fcff6c911d4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1692
    ^ super closeFile
1474
1ad407692b0b Protect #closeFile.
Stefan Vogel <sv@exept.de>
parents: 1446
diff changeset
  1693
! !
1ad407692b0b Protect #closeFile.
Stefan Vogel <sv@exept.de>
parents: 1446
diff changeset
  1694
1ad407692b0b Protect #closeFile.
Stefan Vogel <sv@exept.de>
parents: 1446
diff changeset
  1695
!SoundStream methodsFor:'redefined'!
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1696
274
f45bd0d6ea31 Rename synchronizeOutput --> flush.
Stefan Vogel <sv@exept.de>
parents: 259
diff changeset
  1697
flush
f45bd0d6ea31 Rename synchronizeOutput --> flush.
Stefan Vogel <sv@exept.de>
parents: 259
diff changeset
  1698
    "wait until all sound has been played"
f45bd0d6ea31 Rename synchronizeOutput --> flush.
Stefan Vogel <sv@exept.de>
parents: 259
diff changeset
  1699
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1700
    |fd|
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1701
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1702
    fd := self fileDescriptor.
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1703
%{
274
f45bd0d6ea31 Rename synchronizeOutput --> flush.
Stefan Vogel <sv@exept.de>
parents: 259
diff changeset
  1704
#ifdef IRIS_AUDIO
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1705
    OPJ port;
277
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  1706
    ALport p;
274
f45bd0d6ea31 Rename synchronizeOutput --> flush.
Stefan Vogel <sv@exept.de>
parents: 259
diff changeset
  1707
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1708
    if ((port = __INST(alPort)) != nil) {
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1709
	p = __ALportVal(port);
592
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1710
	while (ALgetfilled(p) > 0) {
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1711
	    sginap(1);
7daa4b2db7eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1712
	}
277
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  1713
    }
353
d1b7f731a331 Avoid callong of getOStype.
Stefan Vogel <sv@exept.de>
parents: 277
diff changeset
  1714
    RETURN(self);
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1715
#endif /* IRIS_AUDIO */
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1716
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1717
#if defined(DEV_AUDIO)
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1718
    if (__isSmallInteger(fd)) {
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1719
	int f = __intVal(fd);
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1720
	/* ... */
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1721
    }
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1722
#endif /* DEV_AUDIO */
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1723
%}.
353
d1b7f731a331 Avoid callong of getOStype.
Stefan Vogel <sv@exept.de>
parents: 277
diff changeset
  1724
    "dont know how to wait on non-iris systems"
277
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  1725
    ^ self
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  1726
!
274
f45bd0d6ea31 Rename synchronizeOutput --> flush.
Stefan Vogel <sv@exept.de>
parents: 259
diff changeset
  1727
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1728
isOpen
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  1729
    handle1 notNil ifTrue:[^ true].
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1730
    handle2 notNil ifTrue:[^ true].
2321
6f4cc7b644db filePointer -> handle migration
Claus Gittinger <cg@exept.de>
parents: 1853
diff changeset
  1731
    ^ handle notNil
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1732
!
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1733
121
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
  1734
nextBytes:count into:anObject startingAt:start
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
  1735
    "read the next count bytes into an object and return the number of
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
  1736
     bytes read or nil on error.
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
  1737
     Use with ByteArrays only."
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
  1738
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
  1739
%{
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
  1740
#ifdef IRIS_AUDIO
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
  1741
  {
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1742
    OBJ port;
121
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
  1743
    ALport p;
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1744
    int cnt, offs, nSamp;
277
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  1745
    int objSize;
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  1746
    char *cp;
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  1747
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1748
    if ((port = __INST(alPort)) != nil) {
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1749
	if (__INST(mode) != _writeonly) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1750
	    if (__bothSmallInteger(count, start)) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1751
		cnt = __intVal(count);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1752
		offs = __intVal(start) - 1;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1753
		p = __ALportVal(port);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1754
		objSize = _Size(anObject) - OHDR_SIZE;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1755
		if ((offs >= 0) && (cnt >= 0) && (objSize >= (cnt + offs))) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1756
		    cp = (char *)__InstPtr(anObject) + OHDR_SIZE + offs;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1757
		    if (__INST(bitsPerSample) == __MKSMALLINT(16))
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1758
			nSamp = cnt / 2;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1759
		    else
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1760
			nSamp = cnt;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1761
		    ALreadsamps(p, cp, nSamp);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1762
		    RETURN ( __MKSMALLINT(cnt) );
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1763
		}
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1764
	    }
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1765
	}
277
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  1766
    }
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  1767
  }
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1768
#endif /* IRIS_AUDIO */
926
2f6d4a59e063 reading
Claus Gittinger <cg@exept.de>
parents: 924
diff changeset
  1769
2f6d4a59e063 reading
Claus Gittinger <cg@exept.de>
parents: 924
diff changeset
  1770
#if defined(DEV_AUDIO)
2f6d4a59e063 reading
Claus Gittinger <cg@exept.de>
parents: 924
diff changeset
  1771
   /*
2f6d4a59e063 reading
Claus Gittinger <cg@exept.de>
parents: 924
diff changeset
  1772
    * redefine to work around a bug in the linux sound driver;
2f6d4a59e063 reading
Claus Gittinger <cg@exept.de>
parents: 924
diff changeset
  1773
    * if a write is interrupted (EINTR), it is not defined, how many
2f6d4a59e063 reading
Claus Gittinger <cg@exept.de>
parents: 924
diff changeset
  1774
    * bytes have been read from the device.
2f6d4a59e063 reading
Claus Gittinger <cg@exept.de>
parents: 924
diff changeset
  1775
    *
2f6d4a59e063 reading
Claus Gittinger <cg@exept.de>
parents: 924
diff changeset
  1776
    * As a workaround, disable signals here to prevent the write from
2f6d4a59e063 reading
Claus Gittinger <cg@exept.de>
parents: 924
diff changeset
  1777
    * being interrupted.
2f6d4a59e063 reading
Claus Gittinger <cg@exept.de>
parents: 924
diff changeset
  1778
    */
2f6d4a59e063 reading
Claus Gittinger <cg@exept.de>
parents: 924
diff changeset
  1779
    int cnt, offs, objSize, n;
2f6d4a59e063 reading
Claus Gittinger <cg@exept.de>
parents: 924
diff changeset
  1780
    char *cp;
2f6d4a59e063 reading
Claus Gittinger <cg@exept.de>
parents: 924
diff changeset
  1781
    OBJ fp;
2f6d4a59e063 reading
Claus Gittinger <cg@exept.de>
parents: 924
diff changeset
  1782
    FILE *f;
2f6d4a59e063 reading
Claus Gittinger <cg@exept.de>
parents: 924
diff changeset
  1783
    int fd;
2f6d4a59e063 reading
Claus Gittinger <cg@exept.de>
parents: 924
diff changeset
  1784
2321
6f4cc7b644db filePointer -> handle migration
Claus Gittinger <cg@exept.de>
parents: 1853
diff changeset
  1785
    if ((fp = __INST(handle)) != nil) {
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1786
	f = __FILEVal(fp);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1787
	if (__INST(mode) != @symbol(writeonly)) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1788
	    if (__bothSmallInteger(count, start)) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1789
		cnt = __intVal(count);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1790
		offs = __intVal(start) - 1;
926
2f6d4a59e063 reading
Claus Gittinger <cg@exept.de>
parents: 924
diff changeset
  1791
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1792
		objSize = _Size(anObject) - OHDR_SIZE;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1793
		if ( (offs >= 0) && (cnt >= 0) && (objSize >= (cnt + offs)) ) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1794
		    do {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1795
			cp = (char *)__InstPtr(anObject) + OHDR_SIZE + offs;
926
2f6d4a59e063 reading
Claus Gittinger <cg@exept.de>
parents: 924
diff changeset
  1796
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1797
			n = cnt;
927
6793d8aecaa7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 926
diff changeset
  1798
/*                        if (n > 4096) n = 4096; */
926
2f6d4a59e063 reading
Claus Gittinger <cg@exept.de>
parents: 924
diff changeset
  1799
# ifdef LINUX
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1800
			sigsetmask(~0);
926
2f6d4a59e063 reading
Claus Gittinger <cg@exept.de>
parents: 924
diff changeset
  1801
# endif
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1802
			if (__INST(buffered) == true) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1803
			    n = fread(cp, 1, n, f);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1804
			} else {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1805
			    fd = fileno(f);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1806
			    n = read(fd, cp, n);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1807
			}
926
2f6d4a59e063 reading
Claus Gittinger <cg@exept.de>
parents: 924
diff changeset
  1808
# ifdef LINUX
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1809
			sigsetmask(0);
926
2f6d4a59e063 reading
Claus Gittinger <cg@exept.de>
parents: 924
diff changeset
  1810
# endif
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1811
			__BEGIN_INTERRUPTABLE__
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1812
			__END_INTERRUPTABLE__
1839
c10cd58ec334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1583
diff changeset
  1813
/* console_printf("SoundStream: read %d bytes\n", n); */
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1814
			if (n > 0) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1815
			    offs += n;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1816
			    cnt -= n;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1817
			} else {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1818
			    if (n < 0) {
1839
c10cd58ec334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1583
diff changeset
  1819
				console_fprintf(stderr, "read error: %d\n", __threadErrno);
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1820
				RETURN (count);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1821
			    }
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1822
			}
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1823
		    } while (cnt);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1824
		}
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1825
		RETURN (count);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1826
	    }
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1827
	}
926
2f6d4a59e063 reading
Claus Gittinger <cg@exept.de>
parents: 924
diff changeset
  1828
    }
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1829
#endif /* DEV_AUDIO */
926
2f6d4a59e063 reading
Claus Gittinger <cg@exept.de>
parents: 924
diff changeset
  1830
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1831
%}.
277
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  1832
    OperatingSystem getOSType = 'irix' ifFalse:[
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1833
	OperatingSystem getOSType = 'win32' ifFalse:[
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1834
	    ^ super nextPutBytes:count from:anObject startingAt:start
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1835
	].
277
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  1836
    ].
2321
6f4cc7b644db filePointer -> handle migration
Claus Gittinger <cg@exept.de>
parents: 1853
diff changeset
  1837
    handle isNil ifTrue:[^ self errorNotOpen].
277
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  1838
    (mode == #writeonly) ifTrue:[^ self errorWriteOnly].
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  1839
    self primitiveFailed
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  1840
!
121
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
  1841
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
  1842
nextPutBytes:count from:anObject startingAt:start
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
  1843
    "write count bytes from an object starting at index start.
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
  1844
     return the number of bytes written or nil on error.
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
  1845
     Redefined, since IRIS audio library cannot be used with stdio.
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
  1846
     (at least I dont know). Use with ByteArrays only."
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
  1847
277
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  1848
%{
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  1849
#ifdef IRIS_AUDIO
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  1850
  {
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1851
    OBJ port;
277
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  1852
    ALport p;
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1853
    int cnt, offs, nSamp;
277
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  1854
    int objSize;
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  1855
    char *cp;
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  1856
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1857
    if ((port = __INST(alPort)) != nil) {
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1858
	if (__INST(mode) != @symbol(readonly)) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1859
	    if (__bothSmallInteger(count, start)) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1860
		cnt = __intVal(count);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1861
		offs = __intVal(start) - 1;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1862
		p = __ALportVal(port);
277
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  1863
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1864
		/*
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1865
		 * compute number of samples
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1866
		 */
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1867
		objSize = _Size(anObject) - OHDR_SIZE;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1868
		if ( (offs >= 0) && (cnt >= 0) && (objSize >= (cnt + offs)) ) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1869
		    cp = (char *)__InstPtr(anObject) + OHDR_SIZE + offs;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1870
		    if (__INST(bitsPerSample) == __MKSMALLINT(16))
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1871
			nSamp = cnt / 2;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1872
		    else
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1873
			nSamp = cnt;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1874
		    ALwritesamps(p, cp, cnt);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1875
		    RETURN ( count );
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1876
		}
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1877
	    }
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1878
	}
277
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  1879
    }
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  1880
  }
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1881
#endif /* IRIS_AUDIO */
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1882
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1883
#ifdef WIN32_DIRECTSOUND
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1884
  {
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1885
    HRESULT hr;
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1886
    DWORD status;
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1887
    LPVOID lpbuf1 = NULL;
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1888
    LPVOID lpbuf2 = NULL;
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1889
    DWORD dwsize1 = 0;
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1890
    DWORD dwsize2 = 0;
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1891
    DWORD playPos, safePos, endWrite;
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1892
    DWORD millis;
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1893
    OBJ oDirectSound, oDSBuffer;
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1894
    LPDIRECTSOUND       t_pDirectSound = (LPDIRECTSOUND)0;
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1895
    LPDIRECTSOUNDBUFFER t_pDSBuffer = (LPDIRECTSOUNDBUFFER)0;
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1896
    int t_cbBufOffset, t_cbBufSize;
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1897
    short *buf;
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1898
    int cnt, offs;
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1899
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1900
    if ((oDSBuffer = __INST(pDSBuffer)) != nil) {
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1901
	t_pDSBuffer = __DSBufferVal(oDSBuffer);
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1902
    }
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1903
    if ((oDirectSound = __INST(pDirectSound)) != nil) {
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1904
	t_pDirectSound = __DirectSoundVal(oDirectSound);
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1905
    }
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1906
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1907
    if (!t_pDSBuffer || !t_pDirectSound) {
1839
c10cd58ec334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1583
diff changeset
  1908
	console_fprintf(stderr, "SoundStream not open!\n");
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1909
	RETURN (0);
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1910
    }
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1911
    t_cbBufOffset = __intVal(__INST(bufferOffset));
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1912
    t_cbBufSize = __intVal(__INST(bufferSize));
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1913
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1914
    cnt = __intVal(count);
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1915
    offs = __intVal(start) - 1;
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1916
    buf = (short *)__InstPtr(anObject) + OHDR_SIZE + offs;
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1917
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1918
    // Should be playing, right?
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1919
    hr = IDirectSoundBuffer_GetStatus(t_pDSBuffer, &status );
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1920
    if (!(status && DSBSTATUS_PLAYING)) {
1839
c10cd58ec334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1583
diff changeset
  1921
	console_fprintf(stderr, "Buffer not playing!\n");
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1922
	RETURN (0);
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1923
    }
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1924
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1925
    // Sleep until we have enough room in buffer.
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1926
    hr = IDirectSoundBuffer_GetCurrentPosition(t_pDSBuffer, &playPos, &safePos );
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1927
    if( hr != DS_OK ) {
1839
c10cd58ec334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1583
diff changeset
  1928
	console_fprintf(stderr, "Cannot get position!\n");
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1929
	RETURN (0);
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1930
    }
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1931
    if( playPos < t_cbBufOffset ) playPos += t_cbBufSize;
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1932
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1933
    endWrite = t_cbBufOffset + (cnt * sizeof(short));
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1934
    while ( playPos < endWrite ) {
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1935
	// Calculate number of milliseconds until we will have room, as
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1936
	// time = distance * (milliseconds/second) / ((bytes/sample) * (samples/second)),
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1937
	// rounded up.
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1938
	millis = (DWORD) (1.0 + ((endWrite - playPos) * 1000.0) / ( sizeof(short) * __intVal(__INST(sampleRate))));
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1939
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1940
	// Sleep for that long
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1941
	Sleep( millis );
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1942
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1943
	// Wake up, find out where we are now
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1944
	hr = IDirectSoundBuffer_GetCurrentPosition(t_pDSBuffer, &playPos, &safePos );
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1945
	if( hr != DS_OK ) {
1839
c10cd58ec334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1583
diff changeset
  1946
	    console_fprintf(stderr, "Cannot get position!\n");
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1947
	    RETURN (0);
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1948
	}
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1949
	if( playPos < t_cbBufOffset ) playPos += t_cbBufSize; // unwrap offset
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1950
    }
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1951
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1952
    // Lock free space in the DS
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1953
    hr = IDirectSoundBuffer_Lock(t_pDSBuffer, t_cbBufOffset, cnt * sizeof(short), &lpbuf1, &dwsize1, &lpbuf2, &dwsize2, 0);
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1954
    if (hr == DS_OK) {
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1955
	// Copy the buffer into the DS
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1956
	CopyMemory(lpbuf1, buf, dwsize1);
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1957
	if(NULL != lpbuf2) CopyMemory(lpbuf2, buf+dwsize1, dwsize2);
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1958
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1959
	// Update our buffer offset and unlock sound buffer
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1960
	t_cbBufOffset = (t_cbBufOffset + dwsize1 + dwsize2) % t_cbBufSize;
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1961
	IDirectSoundBuffer_Unlock(t_pDSBuffer, lpbuf1, dwsize1, lpbuf2, dwsize2);
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1962
    }
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1963
    __INST(buffferOffset) = __MKSMALLINT(t_cbBufOffset);
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1964
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1965
    RETURN (count);
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  1966
  }
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1967
#endif /* WIN32_DIRECTSOUND */
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1968
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  1969
#ifdef WIN32_WAVE
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  1970
  {
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1971
    struct buf *bp;
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  1972
    int len, i, r;
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1973
    int dataLen, offs;
3000
Claus Gittinger <cg@exept.de>
parents: 2833
diff changeset
  1974
    short *buf;
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1975
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1976
    HWAVEOUT t_waveHandle;
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1977
    OBJ oWaveHandle;
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1978
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1979
    if ((oWaveHandle = __INST(waveHandle)) == nil) {
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1980
	RETURN(0);
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1981
    }
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1982
    t_waveHandle = __WaveHandleVal(oWaveHandle);
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1983
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1984
    dataLen = __intVal(count);
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1985
    offs = __intVal(start) - 1;
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  1986
    buf = (short *)__InstPtr(anObject) + OHDR_SIZE + offs;
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  1987
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  1988
    while (dataLen > 0) {
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1989
	if (free_list == NULL && total_buffers < MAXBUF) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1990
	    /* Expand available buffer space */
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1991
	    bp = (struct buf *)malloc(sizeof(struct buf));
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1992
	    total_buffers++;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1993
	} else {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1994
	    if (free_list == NULL) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1995
		/* We must wait for a free buffer */
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1996
		while (free_list == NULL) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1997
		    WaitForSingleObject(free_buffer_event, INFINITE);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1998
		}
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1999
	    }
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2000
	    EnterCriticalSection(&free_list_lock);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2001
	    bp = free_list;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2002
	    free_list = free_list->next;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2003
	    --free_buffers;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2004
	    LeaveCriticalSection(&free_list_lock);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2005
	    r = waveOutUnprepareHeader(t_waveHandle, &bp->hdr, sizeof(WAVEHDR));
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2006
	    if (r != 0) {
1839
c10cd58ec334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1583
diff changeset
  2007
		console_printf("waveOutUnprepareHeader\n");
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2008
		RETURN(self);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2009
	    }
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2010
	}
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2011
	len = min(dataLen, DATALEN);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2012
	bp->hdr.lpData = (char *)bp->data;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2013
	bp->hdr.dwBufferLength = len;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2014
	bp->hdr.dwBytesRecorded = len;
3000
Claus Gittinger <cg@exept.de>
parents: 2833
diff changeset
  2015
	bp->hdr.dwUser = (INT)(bp);
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2016
	bp->hdr.dwFlags = 0;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2017
	bp->hdr.dwLoops = 0;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2018
	r = waveOutPrepareHeader(t_waveHandle, &bp->hdr, sizeof(WAVEHDR));
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2019
	if (r != 0) {
1839
c10cd58ec334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1583
diff changeset
  2020
	    console_printf("waveOutPrepareHeader\n");
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2021
	    RETURN(self);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2022
	}
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2023
	for (i = 0; i < len; i++) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2024
	    bp->data[i] = buf[i];
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2025
	}
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2026
	r = waveOutWrite(t_waveHandle, &bp->hdr, sizeof(WAVEHDR));
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2027
	if (r != 0) {
1839
c10cd58ec334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1583
diff changeset
  2028
	    console_printf("waveOutWrite\n");
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2029
	    RETURN(self);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2030
	}
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2031
	buf += len;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2032
	dataLen -= len;
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  2033
    }
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2034
    RETURN (count);
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  2035
  }
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  2036
#endif /* WIN32_WAVE */
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2037
594
0d62900b49c8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  2038
#if defined(DEV_AUDIO)
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2039
   /*
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2040
    * redefine to work around a bug in the linux sound driver;
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2041
    * if a write is interrupted (EINTR), it is not defined, how many
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2042
    * bytes have been written to the device.
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2043
    * I.e. a retry of the write may lead to ever-playing without ever
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2044
    * finishing.
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2045
    *
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2046
    * As a workaround, disable signals here to prevent the write from
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2047
    * being interrupted.
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2048
    */
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2049
    int cnt, offs, objSize, n;
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2050
    char *cp;
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2051
    OBJ fp;
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2052
    FILE *f;
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2053
    int fd;
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2054
2321
6f4cc7b644db filePointer -> handle migration
Claus Gittinger <cg@exept.de>
parents: 1853
diff changeset
  2055
    if ((fp = __INST(handle)) != nil) {
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2056
	f = __FILEVal(fp);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2057
	if (__INST(mode) != @symbol(readonly)) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2058
	    if (__bothSmallInteger(count, start)) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2059
		cnt = __intVal(count);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2060
		offs = __intVal(start) - 1;
277
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  2061
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2062
		objSize = _Size(anObject) - OHDR_SIZE;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2063
		if ( (offs >= 0) && (cnt >= 0) && (objSize >= (cnt + offs)) ) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2064
		    do {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2065
			cp = (char *)__InstPtr(anObject) + OHDR_SIZE + offs;
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2066
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2067
			n = cnt;
927
6793d8aecaa7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 926
diff changeset
  2068
/*                        if (n > 4096) n = 4096; */
598
1e8d7e905a0c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 597
diff changeset
  2069
# ifdef LINUX
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2070
			sigsetmask(~0);
598
1e8d7e905a0c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 597
diff changeset
  2071
# endif
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2072
			if (__INST(buffered) == true) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2073
			    n = fwrite(cp, 1, n, f);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2074
			} else {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2075
			    fd = fileno(f);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2076
			    n = write(fd, cp, n);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2077
			}
598
1e8d7e905a0c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 597
diff changeset
  2078
# ifdef LINUX
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2079
			sigsetmask(0);
598
1e8d7e905a0c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 597
diff changeset
  2080
# endif
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2081
			__BEGIN_INTERRUPTABLE__
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2082
			__END_INTERRUPTABLE__
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2083
			if (n > 0) {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2084
			    offs += n;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2085
			    cnt -= n;
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2086
			} else {
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2087
			    if (n < 0) {
1839
c10cd58ec334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1583
diff changeset
  2088
				console_fprintf(stderr, "write error: %d\n", __threadErrno);
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2089
				RETURN (count);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2090
			    }
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2091
			}
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2092
		    } while (cnt);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2093
		}
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2094
		RETURN (count);
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2095
	    }
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2096
	}
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2097
    }
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  2098
#endif /* DEV_AUDIO */
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2099
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2100
%}.
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2101
    ^ super nextPutBytes:count from:anObject startingAt:start
277
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  2102
!
121
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
  2103
1480
dbfc64f5af59 Fix #reOpen handling:
Stefan Vogel <sv@exept.de>
parents: 1474
diff changeset
  2104
openWithMode:aMode attributes:attributeSpec
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2105
    |ok error|
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2106
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  2107
%{
36
d046fe84ea67 *** empty log message ***
claus
parents: 31
diff changeset
  2108
#ifdef IRIS_AUDIO
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  2109
  {
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  2110
    ALconfig config;
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  2111
    ALport p;
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  2112
    long params[] = {
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2113
        AL_INPUT_SOURCE, AL_INPUT_MIC,
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2114
        AL_INPUT_RATE, 8000,
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2115
        AL_OUTPUT_RATE, 8000,
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  2116
    };
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  2117
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  2118
    config = ALnewconfig();
217
fcfbc9f71048 underscore cleanup
Claus Gittinger <cg@exept.de>
parents: 152
diff changeset
  2119
    if (__INST(numberOfChannels) == __MKSMALLINT(2))
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2120
        ALsetchannels(config, AL_STEREO);
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  2121
    else
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2122
        ALsetchannels(config, AL_MONO);
277
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  2123
    if (__INST(bitsPerSample) == __MKSMALLINT(16))
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2124
        ALsetwidth(config, AL_SAMPLE_16);
277
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  2125
    else
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2126
        ALsetwidth(config, AL_SAMPLE_8);
277
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  2127
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  2128
    if (__isSmallInteger(__INST(sampleRate)))
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2129
        params[3] = params[5] = __intVal(__INST(sampleRate));
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  2130
277
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  2131
    ALsetparams(AL_DEFAULT_DEVICE, params, 6);
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  2132
    p = ALopenport("smallchat", (char *)_stringVal(aMode), config);
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  2133
    if (p) {
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2134
        OBJ t;
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2135
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2136
        t = __MKEXTERNALADDRESS(p); __INST(alPort) = t; __STORE(self, t);
277
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  2137
    } else {
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2138
        __INST(alPort) = nil;
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2139
        goto out;
277
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  2140
    }
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  2141
    __INST(binary) = true;
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  2142
277
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  2143
    ALfreeconfig(config);
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  2144
    /*
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  2145
     * get the parameters actually installed
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  2146
     */
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  2147
    config = ALgetconfig(p);
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  2148
    switch (ALgetchannels(config)) {
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2149
        default:
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2150
            /* cannot happen */
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2151
        case AL_MONO:
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2152
            __INST(numberOfChannels) = __MKSMALLINT(1);
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2153
            break;
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2154
        case AL_STEREO:
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2155
            __INST(numberOfChannels) = __MKSMALLINT(2);
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2156
            break;
277
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  2157
    }
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  2158
    switch (ALgetwidth(config)) {
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2159
        default:
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2160
            /* cannot happen */
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2161
        case AL_SAMPLE_8:
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2162
            __INST(bitsPerSample) = __MKSMALLINT(8);
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2163
            break;
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2164
        case AL_SAMPLE_16:
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2165
            __INST(bitsPerSample) = __MKSMALLINT(16);
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2166
            break;
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2167
        case AL_SAMPLE_24:
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2168
            __INST(bitsPerSample) = __MKSMALLINT(24);
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2169
            break;
277
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  2170
    }
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  2171
    ALgetparams(AL_DEFAULT_DEVICE, params, 6);
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  2172
    __INST(sampleRate) = __MKSMALLINT(params[3]);
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  2173
277
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  2174
    ALfreeconfig(config);
1422
59ad87529b94 Raise openError on open failure
Stefan Vogel <sv@exept.de>
parents: 1269
diff changeset
  2175
    ok = true;
59ad87529b94 Raise openError on open failure
Stefan Vogel <sv@exept.de>
parents: 1269
diff changeset
  2176
    goto out;
277
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  2177
  }
1422
59ad87529b94 Raise openError on open failure
Stefan Vogel <sv@exept.de>
parents: 1269
diff changeset
  2178
#endif /* IRIS_AUDIO */
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2179
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  2180
#ifdef WIN32_DIRECTSOUND
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2181
  {
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2182
    HRESULT result;
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2183
    LPDIRECTSOUND       t_pDirectSound;
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2184
    LPDIRECTSOUNDBUFFER t_pDSBuffer, t_pDSPrimeBuffer;
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2185
    WAVEFORMATEX        wfFormat;
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2186
    DSBUFFERDESC        dsbdDesc, primarydsbDesc;
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2187
    BYTE                *pDSBuffData;
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2188
    int                 t_cbBufSize;
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2189
    int                 dwDataLen;
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2190
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2191
    /* Create the DS object */
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2192
    if ((result = DirectSoundCreate(NULL, &t_pDirectSound, NULL)) != DS_OK) {
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2193
        console_fprintf(stderr,"SoundStream: Cannot open default sound device!!\n");
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2194
        goto out;
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2195
    }
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2196
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2197
    /* Define the wave format structure */
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2198
    wfFormat.wFormatTag = WAVE_FORMAT_PCM;
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2199
    wfFormat.nChannels = __intVal(__INST(numberOfChannels));
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2200
    wfFormat.nSamplesPerSec = __intVal(__INST(sampleRate));
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2201
    wfFormat.wBitsPerSample = __intVal(__INST(bitsPerSample));
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2202
    wfFormat.nBlockAlign = wfFormat.nChannels * wfFormat.wBitsPerSample / 8;
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2203
    wfFormat.nAvgBytesPerSec = wfFormat.nSamplesPerSec * wfFormat.nBlockAlign;
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2204
    wfFormat.cbSize = 0;
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  2205
#  if 0
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2206
    /* Setup the primary DS buffer description */
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2207
    ZeroMemory(&primarydsbDesc, sizeof(DSBUFFERDESC));
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2208
    primarydsbDesc.dwSize = sizeof(DSBUFFERDESC);
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2209
    primarydsbDesc.dwFlags = DSBCAPS_PRIMARYBUFFER;
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2210
    primarydsbDesc.dwBufferBytes = 0;
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2211
    primarydsbDesc.lpwfxFormat = NULL;
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2212
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2213
    /* Create the primary DS buffer */
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2214
    if ((result = IDirectSound_CreateSoundBuffer(t_pDirectSound, &primarydsbDesc,
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2215
                                                 &t_pDSPrimeBuffer, NULL)) != DS_OK) {
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2216
        console_fprintf(stderr,"SoundStream: Cannot get the primary DS buffer address!\n");
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2217
        IDirectSound_Release(t_pDirectSound);
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2218
        goto out;
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2219
    }
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2220
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2221
    /* Set the primary DS buffer sound format.  We have to do this because
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2222
       the default primary buffer is 8-bit, 22kHz! */
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2223
    if ((result = IDirectSoundBuffer_SetFormat(t_pDSPrimeBuffer, &wfFormat)) != DS_OK) {
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2224
        console_fprintf(stderr,"SoundStream: Cannot set the primary DS buffer to proper sound format (%x) (%d)!\n", result, result);
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2225
        IDirectSoundBuffer_Stop(t_pDSPrimeBuffer);
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2226
        IDirectSoundBuffer_Release(t_pDSPrimeBuffer);
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2227
        IDirectSound_Release(t_pDirectSound);
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2228
        goto out;
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2229
    }
1422
59ad87529b94 Raise openError on open failure
Stefan Vogel <sv@exept.de>
parents: 1269
diff changeset
  2230
#  endif /* 0 */
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2231
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2232
    /* Setup the secondary DS buffer description */
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2233
    t_cbBufSize = RT_BUFFER_SIZE * sizeof(short) * NBUFS;
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  2234
    __INST(bufferSize) = __MKSMALLINT(t_cbBufSize);
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2235
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2236
    ZeroMemory(&dsbdDesc, sizeof(DSBUFFERDESC));
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2237
    dsbdDesc.dwSize = sizeof(DSBUFFERDESC);
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2238
    dsbdDesc.dwFlags = DSBCAPS_GLOBALFOCUS;
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2239
    dsbdDesc.dwBufferBytes = t_cbBufSize;
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2240
    dsbdDesc.lpwfxFormat = &wfFormat;
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2241
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2242
    /* Create the secondary DS buffer */
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2243
    if ((result = IDirectSound_CreateSoundBuffer(t_pDirectSound, &dsbdDesc, &t_pDSBuffer, NULL)) != DS_OK) {
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2244
        console_fprintf(stderr,"SoundStream: couldn't create sound buffer!\n");
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2245
        IDirectSoundBuffer_Stop(t_pDSPrimeBuffer);
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2246
        IDirectSoundBuffer_Release(t_pDSPrimeBuffer);
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2247
        IDirectSound_Release(t_pDirectSound);
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2248
        goto out;
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2249
    }
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2250
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2251
    /* Lock the DS buffer */
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2252
    if ((result = IDirectSoundBuffer_Lock(t_pDSBuffer, 0, t_cbBufSize, (LPLPVOID)&pDSBuffData,
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2253
                                          &dwDataLen, NULL, NULL, 0)) != DS_OK) {
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2254
        console_fprintf(stderr,"SoundStream: couldn't lock sound buffer!\n");
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2255
        IDirectSoundBuffer_Stop(t_pDSBuffer);
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2256
        IDirectSoundBuffer_Stop(t_pDSPrimeBuffer);
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2257
        IDirectSoundBuffer_Release(t_pDSPrimeBuffer);
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2258
        IDirectSound_Release(t_pDirectSound);
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2259
        goto out;
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2260
    }
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2261
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2262
    /* Zero the DS buffer */
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2263
    ZeroMemory(pDSBuffData, dwDataLen);
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2264
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2265
    /* Unlock the DS buffer */
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2266
    if ((result = IDirectSoundBuffer_Unlock(t_pDSBuffer, pDSBuffData, dwDataLen, NULL, 0)) != DS_OK) {
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2267
        console_fprintf(stderr,"SoundStream: couldn't unlock sound buffer!\n");
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2268
        IDirectSoundBuffer_Stop(t_pDSBuffer);
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2269
        IDirectSoundBuffer_Stop(t_pDSPrimeBuffer);
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2270
        IDirectSoundBuffer_Release(t_pDSPrimeBuffer);
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2271
        IDirectSound_Release(t_pDirectSound);
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2272
        goto out;
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2273
    }
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2274
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  2275
    __INST(bufferOffset) = __MKSMALLINT(0);  // reset last write position to start of buffer
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2276
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2277
    /* Start the buffer playback */
715
b2950d207977 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
  2278
    if ((result = IDirectSoundBuffer_Play(t_pDSBuffer, 0, 0, DSBPLAY_LOOPING) != DS_OK)) {
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2279
        console_fprintf(stderr,"SoundStream: couldn't play sound buffer!\n");
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2280
        IDirectSoundBuffer_Stop(t_pDSBuffer);
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2281
        IDirectSoundBuffer_Stop(t_pDSPrimeBuffer);
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2282
        IDirectSoundBuffer_Release(t_pDSPrimeBuffer);
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2283
        IDirectSound_Release(t_pDirectSound);
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2284
        ok = false;
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2285
        goto out;
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2286
    }
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2287
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2288
    {
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2289
        OBJ t;
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2290
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2291
        t = __MKEXTERNALADDRESS(t_pDSBuffer); __INST(pDSBuffer) = t; __STORE(self, t);
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2292
        t = __MKEXTERNALADDRESS(t_pDirectSound); __INST(pDirectSound) = t; __STORE(self, t);
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2293
    }
1422
59ad87529b94 Raise openError on open failure
Stefan Vogel <sv@exept.de>
parents: 1269
diff changeset
  2294
    ok = true;
59ad87529b94 Raise openError on open failure
Stefan Vogel <sv@exept.de>
parents: 1269
diff changeset
  2295
    goto out;
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2296
  }
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  2297
#endif /* WIN32_DIRECTSOUND */
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  2298
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  2299
#ifdef WIN32_WAVE
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  2300
  {
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  2301
    PCMWAVEFORMAT waveFormat;
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  2302
    int r;
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2303
    HWAVEOUT t_waveHandle;
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2304
    OBJ oWaveHandle;
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  2305
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2306
    if ((oWaveHandle = __INST(waveHandle)) != nil) {
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2307
        ok = false;
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2308
        goto out;
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  2309
    }
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  2310
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  2311
    waveFormat.wf.wFormatTag = WAVE_FORMAT_PCM;
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2312
    waveFormat.wf.nChannels = __intVal(__INST(numberOfChannels));
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2313
    waveFormat.wf.nSamplesPerSec = __intVal(__INST(sampleRate));
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2314
    waveFormat.wBitsPerSample = __intVal(__INST(bitsPerSample));
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2315
    waveFormat.wf.nBlockAlign = waveFormat.wf.nChannels * waveFormat.wBitsPerSample / 8;
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2316
    waveFormat.wf.nAvgBytesPerSec = waveFormat.wf.nSamplesPerSec * waveFormat.wf.nBlockAlign;
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  2317
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2318
    r = waveOutOpen(&t_waveHandle,
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2319
                    WAVE_MAPPER,
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2320
                    (WAVEFORMAT *)&waveFormat,
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2321
                    (DWORD_PTR)waveCallBack,
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2322
                    (DWORD_PTR)0,
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2323
                    CALLBACK_FUNCTION);
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  2324
    if (r != 0) {
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2325
        console_printf("waveOutOpen\n");
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2326
        ok = false;
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2327
        goto out;
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  2328
    }
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  2329
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2330
    (void)waveOutReset(t_waveHandle);
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  2331
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  2332
    free_list = NULL;
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  2333
    InitializeCriticalSection(&free_list_lock);
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  2334
    free_buffers = 0;
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  2335
    free_buffer_event = CreateEvent(NULL, FALSE, FALSE, NULL);
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  2336
    total_buffers = 0;
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  2337
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2338
    {
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2339
        OBJ t;
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2340
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2341
        t = __MKEXTERNALADDRESS(t_waveHandle); __INST(waveHandle) = t; __STORE(self, t);
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2342
    }
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2343
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  2344
# if 0
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  2345
    /*
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  2346
     * HACK: If we immediately start writing valid audio data to the device
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  2347
     * then the sound is choppy in the beginning. Writing a null packet to
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  2348
     * to the device first seems to fix this problem although I have no idea
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  2349
     * why - DAC
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  2350
     */
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  2351
    {
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2352
        char null[DATALEN];
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2353
        int i;
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2354
        for (i = 0; i < DATALEN; i++) {
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2355
            null[i] = 127;
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2356
        }
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2357
        audioWrite(null, DATALEN);
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  2358
    }
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  2359
# endif /* 0 */
1422
59ad87529b94 Raise openError on open failure
Stefan Vogel <sv@exept.de>
parents: 1269
diff changeset
  2360
    ok = true;
59ad87529b94 Raise openError on open failure
Stefan Vogel <sv@exept.de>
parents: 1269
diff changeset
  2361
    goto out;
721
99f4c93ca492 preps for WaveOut (WIN32)
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
  2362
  }
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  2363
#endif /* !WIN32_DIRECTSOUND */
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2364
921
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
  2365
#ifdef DEV_AUDIO
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  2366
  {
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  2367
      int __fd;
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  2368
      int __mode;
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  2369
      FILE *f;
921
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
  2370
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  2371
      if (strcmp(__stringVal(aMode), "w") == 0) {
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2372
          __mode = O_WRONLY;
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  2373
      } else if (strcmp(__stringVal(aMode), "r") == 0) {
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2374
          __mode = O_RDONLY;
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  2375
      } else {
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2376
          __mode = O_RDWR;
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  2377
      }
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  2378
      do {
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2379
          __BEGIN_INTERRUPTABLE__
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2380
          __fd = open((char *) __stringVal(__INST(pathName)), __mode /* |O_NDELAY */);
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2381
          __END_INTERRUPTABLE__
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2382
      } while ((__fd < 0) && (errno == EINTR));
921
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
  2383
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  2384
      if (__fd >= 0) {
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2385
          /*
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2386
           * make it a FILE *
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2387
           */
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2388
          f = fdopen(__fd, __stringVal(aMode));
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2389
          if (! f) {
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2390
              error = __mkSmallInteger(errno);
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2391
              __BEGIN_INTERRUPTABLE__
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2392
              close(__fd);
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2393
              __END_INTERRUPTABLE__
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2394
              ok = false;
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2395
              goto out;
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2396
          }
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2397
          setbuf(f, NULL);
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2398
          __INST(buffered) = false;
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2399
          __INST(handle) = __MKEXTERNALADDRESS(f);
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2400
          __STORESELF(handle);
932
1c9375cf97fc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
  2401
934
157a7640c5cb *** empty log message ***
ps
parents: 932
diff changeset
  2402
#if defined(PCM_ENABLE_OUTPUT) && defined(PCM_ENABLE_INPUT)
157a7640c5cb *** empty log message ***
ps
parents: 932
diff changeset
  2403
# if defined(SNDCTL_DSP_SETTRIGGER)
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2404
          if (__mode == O_RDWR) {
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2405
              int enable_bits = ~(PCM_ENABLE_OUTPUT|PCM_ENABLE_INPUT);
932
1c9375cf97fc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 927
diff changeset
  2406
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2407
              if (ioctl(__fd, SNDCTL_DSP_SETTRIGGER, &enable_bits) == -1)
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2408
              {
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2409
                  console_fprintf(stderr, "can't request synchronous start of fullduplex operation");
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2410
              }
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2411
          }
934
157a7640c5cb *** empty log message ***
ps
parents: 932
diff changeset
  2412
# endif
157a7640c5cb *** empty log message ***
ps
parents: 932
diff changeset
  2413
#endif
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2414
          ok = true;
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2415
          goto out;
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2416
      } else {
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2417
          error = __mkSmallInteger(errno);
1583
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  2418
      }
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  2419
  }
a45ac92afbc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1556
diff changeset
  2420
#endif /* DEV_AUDIO */
921
c15fe619a1be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
  2421
1422
59ad87529b94 Raise openError on open failure
Stefan Vogel <sv@exept.de>
parents: 1269
diff changeset
  2422
out:;
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2423
%}.
1422
59ad87529b94 Raise openError on open failure
Stefan Vogel <sv@exept.de>
parents: 1269
diff changeset
  2424
    ok == false ifTrue:[
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2425
        lastErrorNumber := error.
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2426
        self openError:error.
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2427
        "normally not reached"
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2428
        ^ nil.
1422
59ad87529b94 Raise openError on open failure
Stefan Vogel <sv@exept.de>
parents: 1269
diff changeset
  2429
    ].
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2430
1422
59ad87529b94 Raise openError on open failure
Stefan Vogel <sv@exept.de>
parents: 1269
diff changeset
  2431
    ok isNil ifTrue:[
3216
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2432
        "its a regular file open (i.e. /dev/audio) "
fdbf3212c1e9 class: SoundStream
Stefan Vogel <sv@exept.de>
parents: 3156
diff changeset
  2433
        ^ super openWithMode:aMode attributes:attributeSpec.
1422
59ad87529b94 Raise openError on open failure
Stefan Vogel <sv@exept.de>
parents: 1269
diff changeset
  2434
    ].
59ad87529b94 Raise openError on open failure
Stefan Vogel <sv@exept.de>
parents: 1269
diff changeset
  2435
59ad87529b94 Raise openError on open failure
Stefan Vogel <sv@exept.de>
parents: 1269
diff changeset
  2436
    Lobby register:self.
59ad87529b94 Raise openError on open failure
Stefan Vogel <sv@exept.de>
parents: 1269
diff changeset
  2437
    ^ self.
277
ab17540f022a oops - your last checkin was garbage
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
  2438
! !
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  2439
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  2440
!SoundStream methodsFor:'sine wave generation'!
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  2441
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2442
playSine16:freq forSeconds:seconds
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2443
    "output some tone for some time
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2444
     in S16 audioFormat - a test method"
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2445
923
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2446
    |buffer numSamples val scale isUnsigned|
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2447
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2448
    (audioFormat startsWith:#U16) ifFalse:[
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2449
	(audioFormat startsWith:#S16) ifFalse:[
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2450
	    self error:'must be in 16bit mode' mayProceed:true.
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2451
	    ^ self
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2452
	]
923
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2453
    ].
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2454
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2455
    numSamples := (self sampleRate * seconds) truncated.
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2456
    buffer := WordArray new:numSamples.
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2457
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2458
    "fill it with a sine wave"
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2459
923
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2460
    isUnsigned := audioFormat startsWith:#U16.
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2461
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2462
    scale := freq * 2 * (Float pi).
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2463
    1 to:numSamples do:[:i |
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2464
	val := (scale * i / self sampleRate) sin.
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2465
	val := (val * 16r7FFF) rounded bitAnd:16rFFFF.
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2466
	isUnsigned ifTrue:[
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2467
	    val := val + 32768
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2468
	].
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2469
	buffer at:i put:val
714
ebeacc2e07bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  2470
    ].
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2471
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2472
    self nextPutBytes:(numSamples*2) from:buffer startingAt:1
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2473
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2474
    "
923
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2475
     SoundStream writing setAudioFormat:#S16; playSine16:440 forSeconds:2; close
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2476
     SoundStream writing setAudioFormat:#S16; playSine16:880 forSeconds:2; close
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2477
     SoundStream writing setAudioFormat:#S16; playSine16:1760 forSeconds:2; close
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2478
     SoundStream writing setAudioFormat:#S16; playSine16:3520 forSeconds:2; close
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2479
     SoundStream writing tuneTone:440; close
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2480
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2481
     SoundStream writing setAudioFormat:#U16; playSine16:880 forSeconds:2; close
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2482
     SoundStream writing setAudioFormat:#U16_LE; playSine16:880 forSeconds:2; close
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2483
    "
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2484
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2485
    "Modified: / 31.1.1999 / 12:12:41 / cg"
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2486
!
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2487
788
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2488
testMelody
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2489
    3 timesRepeat:[
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2490
	self playSine16:220 forSeconds:0.5.
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2491
	self playSine16:440 forSeconds:0.5.
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2492
	self playSine16:880 forSeconds:0.5.
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2493
	self playSine16:1760 forSeconds:0.5.
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2494
	self playSine16:3520 forSeconds:0.5.
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2495
    ]
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2496
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2497
    "
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2498
     self writing testMelody; close
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2499
    "
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2500
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2501
    "Created: / 31.1.1999 / 12:07:45 / cg"
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2502
    "Modified: / 31.1.1999 / 12:16:09 / cg"
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2503
!
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2504
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2505
tuneTone
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2506
    ^ self tuneTone:440
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  2507
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  2508
    "
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  2509
     SoundStream writing tuneTone; close
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  2510
     SoundStream writing setSampleRate:4000; tuneTone; close
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  2511
     SoundStream writing setSampleRate:8000; tuneTone; close
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  2512
     SoundStream writing setSampleRate:10000; tuneTone; close
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  2513
     SoundStream writing setSampleRate:20000; tuneTone; close
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  2514
     SoundStream writing setSampleRate:40000; tuneTone; close
923
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2515
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2516
     SoundStream writing setSampleRate:40000; dumpSettings; close
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  2517
     SoundStream writing setSampleRate:20000; dumpSettings; close
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  2518
    "
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  2519
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2520
    "Modified: / 31.1.1999 / 12:06:27 / cg"
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2521
!
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2522
597
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2523
tuneTone16:freq
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2524
    "output some tone for 3 seconds in S16 audioFormat - a test method"
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2525
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2526
    |buffer numSamples val scale oldFormat|
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2527
923
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2528
    (audioFormat startsWith:#U16) ifFalse:[
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2529
	(audioFormat startsWith:#S16) ifFalse:[
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2530
	    self error:'must be in 16bit mode' mayProceed:true.
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2531
	    ^ self
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2532
	]
923
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2533
    ].
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2534
597
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2535
    "allocate memory for 1sec playing time"
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2536
    numSamples := self sampleRate.
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2537
    buffer := WordArray new:numSamples.
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2538
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2539
    "fill it with a sine wave"
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2540
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2541
    scale := freq * 2 * (Float pi).
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2542
    1 to:numSamples do:[:i |
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2543
	val := (scale * i / numSamples) sin.
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2544
	val := (val * 16r7FFF) rounded bitAnd:16rFFFF.
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2545
	audioFormat == #U16 ifTrue:[
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2546
	    val := val + 32768
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2547
	].
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2548
	buffer at:i put:val
597
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2549
    ].
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2550
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2551
    oldFormat := audioFormat.
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2552
    self setAudioFormat:#S16.
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2553
    1 to:3 do:[:s |
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2554
	self nextPutBytes:(numSamples*2) from:buffer startingAt:1
597
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2555
    ].
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2556
    self setAudioFormat:oldFormat.
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2557
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2558
    "of course, the frequency should be below half the
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2559
     sampleRate - hear below ...
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2560
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2561
     SoundStream writing setSampleRate:4000; tuneTone16:440; close
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2562
     SoundStream writing setSampleRate:8000; tuneTone16:440; close
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2563
     SoundStream writing setSampleRate:10000; tuneTone16:440; close
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2564
     SoundStream writing setSampleRate:20000; tuneTone16:440; close
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2565
     SoundStream writing setSampleRate:40000; tuneTone16:440; close
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2566
    "
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2567
714
ebeacc2e07bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  2568
    "Modified: / 21.12.1998 / 09:11:30 / cg"
597
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2569
!
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2570
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2571
tuneTone8:freq
597
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2572
    "output some tone for 3 seconds in U8 audioFormat - a test method"
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2573
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2574
    |buffer numSamples val scale oldFormat|
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  2575
923
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2576
    (audioFormat == #U8) ifFalse:[
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2577
	(audioFormat == #S8) ifFalse:[
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2578
	    self error:'must be in 8bit mode' mayProceed:true.
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2579
	    ^ self
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2580
	]
923
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2581
    ].
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2582
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  2583
    "allocate memory for 1sec playing time"
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  2584
    numSamples := self sampleRate.
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  2585
    buffer := ByteArray new:numSamples.
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  2586
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  2587
    "fill it with a sine wave"
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  2588
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2589
    scale := freq * 2 * (Float pi).
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  2590
    1 to:numSamples do:[:i |
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2591
	val := (scale * i / numSamples) sin.
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2592
	val := (val * 127 + 128) rounded.
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2593
	buffer at:i put:val
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  2594
    ].
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  2595
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2596
    oldFormat := audioFormat.
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2597
    self setAudioFormat:#U8.
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  2598
    1 to:3 do:[:s |
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2599
	self nextPutBytes:numSamples from:buffer startingAt:1
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2600
    ].
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2601
    self setAudioFormat:oldFormat.
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2602
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2603
    "of course, the frequency should be below half the
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2604
     sampleRate - hear below ...
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  2605
593
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2606
     SoundStream writing tuneTone; close
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2607
     SoundStream writing setSampleRate:4000; tuneTone:440; close
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2608
     SoundStream writing setSampleRate:4000; tuneTone:2000; close
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2609
     SoundStream writing setSampleRate:8000; tuneTone:440; close
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2610
     SoundStream writing setSampleRate:8000; tuneTone:2000; close
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2611
     SoundStream writing setSampleRate:8000; tuneTone:4000; close
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2612
     SoundStream writing setSampleRate:10000; tuneTone:440; close
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2613
     SoundStream writing setSampleRate:10000; tuneTone:2000; close
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2614
     SoundStream writing setSampleRate:10000; tuneTone:4000; close
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2615
     SoundStream writing setSampleRate:20000; tuneTone:440; close
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2616
     SoundStream writing setSampleRate:20000; tuneTone:2000; close
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2617
     SoundStream writing setSampleRate:20000; tuneTone:4000; close
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2618
     SoundStream writing setSampleRate:20000; tuneTone:8000; close
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2619
     SoundStream writing setSampleRate:40000; tuneTone:440; close
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2620
     SoundStream writing setSampleRate:40000; tuneTone:2000; close
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2621
     SoundStream writing setSampleRate:40000; tuneTone:4000; close
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2622
     SoundStream writing setSampleRate:40000; tuneTone:8000; close
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2623
     SoundStream writing setSampleRate:40000; tuneTone:10000; close
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2624
    "
719f9d1c7bbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2625
597
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2626
    "Modified: / 15.12.1997 / 13:43:05 / cg"
722
0c3c1f866eb4 support waveOut
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
  2627
    "Created: / 31.1.1999 / 12:05:17 / cg"
597
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2628
!
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2629
788
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2630
tuneTone:freq
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2631
    ((audioFormat startsWith:#S16)
923
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2632
    or:[audioFormat startsWith:#U16]) ifTrue:[
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2633
	^ self tuneTone16:freq
788
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2634
    ].
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2635
    audioFormat == #MU_LAW ifTrue:[
1556
8a78c9a5a8f7 STORE macro (gcc 3.4 bug workaround)
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  2636
	^ self tuneToneMU:freq
788
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2637
    ].
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2638
    self tuneTone8:freq
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2639
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2640
    "
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2641
     SoundStream writing tuneTone:880; close
923
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2642
     SoundStream writing setSampleRate:4000; tuneTone:440; close
788
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2643
     SoundStream writing setSampleRate:4000; tuneTone:880; close
923
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2644
     SoundStream writing setSampleRate:8000; tuneTone:440; close
788
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2645
     SoundStream writing setSampleRate:8000; tuneTone:880; close
923
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2646
     SoundStream writing setSampleRate:10000; tuneTone:440; close
788
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2647
     SoundStream writing setSampleRate:10000; tuneTone:880; close
923
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2648
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2649
     SoundStream writing setSampleRate:20000; tuneTone:440; close
788
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2650
     SoundStream writing setSampleRate:20000; tuneTone:880; close
923
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2651
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2652
     SoundStream writing setSampleRate:40000; tuneTone:440; close
788
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2653
     SoundStream writing setSampleRate:40000; tuneTone:880; close
923
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2654
     SoundStream writing setSampleRate:40000; tuneTone:1760; close
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2655
     SoundStream writing setSampleRate:40000; tuneTone:3520; close
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2656
     SoundStream writing setSampleRate:40000; tuneTone:7020; close
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2657
     SoundStream writing setSampleRate:40000; tuneTone:14040; close
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2658
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2659
     SoundStream writing setSampleRate:44100; tuneTone:440; close
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2660
     SoundStream writing setSampleRate:44100; tuneTone:880; close
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2661
     SoundStream writing setSampleRate:44100; tuneTone:1760; close
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2662
     SoundStream writing setSampleRate:44100; tuneTone:3520; close
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2663
     SoundStream writing setSampleRate:44100; tuneTone:7020; close
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2664
     SoundStream writing setSampleRate:44100; tuneTone:14040; close
cfb86334aebf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  2665
788
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2666
     SoundStream writing setSampleRate:20000; dumpSettings; close
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2667
    "
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2668
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2669
    "Modified: / 31.1.1999 / 12:07:14 / cg"
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2670
!
5cf69ceb1166 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  2671
597
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2672
tuneToneMU:freq
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2673
    "output some tone for 3 seconds in MU_LAW audioFormat - a test method"
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2674
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2675
    |buffer numSamples val scale oldFormat|
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2676
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2677
    "allocate memory for 1sec playing time"
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2678
    numSamples := self sampleRate.
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2679
    buffer := ByteArray new:numSamples.
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2680
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2681
    "fill it with a sine wave"
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2682
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2683
    scale := freq * 2 * (Float pi).
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2684
    1 to:numSamples do:[:i |
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2685
	val := (scale * i / numSamples) sin.
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2686
	val := (val * 16r7FFF) rounded.
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2687
	buffer at:i put:(self class linear16ToUlaw:val)
597
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2688
    ].
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2689
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2690
    oldFormat := audioFormat.
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2691
    self setAudioFormat:#MU_LAW.
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2692
    1 to:3 do:[:s |
712
9e853d04f52b first attempt in win32 audio
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2693
	self nextPutBytes:numSamples from:buffer startingAt:1
597
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2694
    ].
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2695
    self setAudioFormat:oldFormat.
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2696
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2697
    "of course, the frequency should be below half the
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2698
     sampleRate - hear below ...
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2699
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2700
     SoundStream writing setSampleRate:8000; tuneToneMU:440; close
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2701
     SoundStream writing setSampleRate:10000; tuneToneMU:440; close
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2702
     SoundStream writing setSampleRate:20000; tuneToneMU:440; close
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2703
     SoundStream writing setSampleRate:40000; tuneToneMU:440; close
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2704
    "
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2705
42dafea485d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 596
diff changeset
  2706
    "Modified: / 15.12.1997 / 13:46:19 / cg"
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
  2707
! !
121
606a3ccd3682 linux fixes (cut off when closing)
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
  2708
152
89d93f115cb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 121
diff changeset
  2709
!SoundStream class methodsFor:'documentation'!
89d93f115cb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 121
diff changeset
  2710
89d93f115cb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 121
diff changeset
  2711
version
3482
a78459c5bfaf class: SoundStream
Claus Gittinger <cg@exept.de>
parents: 3226
diff changeset
  2712
    ^ '$Header: /cvs/stx/stx/libbasic2/SoundStream.st,v 1.81 2015-02-10 20:46:46 cg Exp $'
2418
4ea40741b2b5 Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  2713
!
4ea40741b2b5 Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  2714
4ea40741b2b5 Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents: 2321
diff changeset
  2715
version_CVS
3482
a78459c5bfaf class: SoundStream
Claus Gittinger <cg@exept.de>
parents: 3226
diff changeset
  2716
    ^ '$Header: /cvs/stx/stx/libbasic2/SoundStream.st,v 1.81 2015-02-10 20:46:46 cg Exp $'
918
c93d55269f9d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 861
diff changeset
  2717
! !
1151
5963256af171 do not depend on TimeStamp - TimeStamp to return seconds-integer
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  2718
3154
23ac6f3e69b6 Initialize in instance initialize method insted in #new
Stefan Vogel <sv@exept.de>
parents: 3000
diff changeset
  2719
596
8d0920f791f1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  2720
SoundStream initialize!