Hi,

I am using the following Python Script to create an audiofile
for aucat -program to play:

------------------- Script starts -------------------
# Create a soundfile in AU format playing a sine wave
# of a given frequency, duration and volume

import os
import struct
import math

def au_file(name='test.au', freq=300, dur=5000, vol=0.5):
    """
    creates an AU format audio file of a sine wave
    of frequency freq (Hz)
    for duration dur (milliseconds)
    at volume vol (max is 1.0)
    """
    fout = open(name, 'wb')
    '''
    Header:
        word0: magic number 0x2e736e64 (".snd" in ascii)
        word1: data offset in bytes. Minimum is 24
        word2: data_size in bytes
        word3: encoding. 3 = 16bit linear PCM
        word4: sampling_rate. 8000 samples/second
        word5: channel. 1 = mono
    '''

    fout.write('.snd' + struct.pack('>5L', 24, 16*dur, 3, 8000, 1))
    factor = 2 * math.pi * freq/8000
    # Write data
    for seg in range(16 * dur):
        # sine wave calculations
        sin_seg = math.sin(seg * factor)
        fout.write(struct.pack('b', vol * 127 * sin_seg))
    fout.close()

# Command line test
if __name__ == '__main__':
    au_file(name='sound440.au', freq=440, dur=2000, vol=0.5)

------------------- Script ends -------------------

When I play the created file "sound440.au" in Windows I corretly
get 2 seconds of 440 Hz sound. However, when I play it in
OpenBSD v4.4 with the following command:

        aucat -i sound440.au
        /dev/audio: playing s16le,0:1,48000Hz
        sound440.au: s16le,0:1,44100Hz -> s16le,0:1,48000Hz
        sound440.au: reading s16le,0:1,44100Hz
        filling buffers...
        starting device ...
        draining buffers...


I get sound lasting only a fraction of a second. Making the sound sample
longer, 4000 ms for example, I get message "filling buffers..." which
goes on for minutes. Running command

        cat sound440.au > /dev/sound

gives even shorter sound. What am I missing?

------------------- audioctl output starts -------------------
name=440MX AC97
version=0x00
config=auich0
encodings=ulinear:8*,mulaw:8*,alaw:8*,slinear:8*,slinear_le:16,ulinear_le:16*,slinear_be:16*,ulinear_be:16*
properties=full_duplex,mmap,independent
full_duplex=0
fullduplex=0
blocksize=9600
hiwat=6
lowat=1
output_muted=0
monitor_gain=0
mode=
play.rate=48000
play.channels=2
play.precision=16
play.encoding=slinear_le
play.gain=255
play.balance=32
play.port=0x0
play.avail_ports=0x0
play.seek=0
play.samples=0
play.eof=0
play.pause=1
play.error=0
play.waiting=0
play.open=0
play.active=0
play.buffer_size=65536
play.block_size=9600
play.errors=0
record.rate=48000
record.channels=2
record.precision=16
record.encoding=slinear_le
record.gain=191
record.balance=32
record.port=0x1
record.avail_ports=0x7
record.seek=0
record.samples=0
record.eof=0
record.pause=1
record.error=0
record.waiting=0
record.open=0
record.active=0
record.buffer_size=65536
record.block_size=9600
record.errors=0

------------------- audioctl output stops -------------------


------------------- dmesg starts -------------------
OpenBSD 4.4 (GENERIC) #0: Sat Dec  6 17:39:06 EET 2008
    [EMAIL PROTECTED]:/usr/src/sys/arch/i386/compile/GENERIC
cpu0: Intel Pentium III ("GenuineIntel" 686-class) 498 MHz
cpu0: FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,MMX,FXSR,SSE
real mem  = 267874304 (255MB)
avail mem = 250580992 (238MB)
mainbus0 at root
bios0 at mainbus0: AT/286+ BIOS, date 10/04/00, BIOS32 rev. 0 @ 0xfd8a0, SMBIOS rev. 2.3 @ 0xfff0000 (45 entries)
bios0: vendor Phoenix/FUJITSU version "Version  1.08" date 10/04/2000
bios0: FUJITSU SIEMENS LIFEBOOK S Series
apm0 at bios0: Power Management spec V1.2
apm0: AC on, battery charge unknown
acpi at bios0 function 0x0 not configured
pcibios0 at bios0: rev 2.1 @ 0xfd8a0/0x760
pcibios0: PCI IRQ Routing Table rev 1.0 @ 0xfdf60/128 (6 entries)
pcibios0: PCI Interrupt Router at 000:07:0 ("Intel 82371FB ISA" rev 0x00)
pcibios0: PCI bus #2 is the last bus
bios0: ROM list: 0xc0000/0xc000
cpu0 at mainbus0
pci0 at mainbus0 bus 0: configuration mode 1 (no bios)
pchb0 at pci0 dev 0 function 0 "Intel 82440MX Host" rev 0x01
auich0 at pci0 dev 0 function 1 "Intel 82440MX AC97" rev 0x00: irq 9, 440MX AC97
auich0: DMA bug workaround enabled
ac97: codec id 0x83847609 (SigmaTel STAC9721/23)
ac97: codec features 18 bit DAC, 18 bit ADC, SigmaTel 3D
audio0 at auich0
pcib0 at pci0 dev 7 function 0 "Intel 82440MX ISA" rev 0x01
pciide0 at pci0 dev 7 function 1 "Intel 82440MX IDE" rev 0x00: DMA, channel 0 wired to compatibility, channel 1 wired to compatibility
wd0 at pciide0 channel 0 drive 0: <TRANSCEND>
wd0: 1-sector PIO, LBA, 1946MB, 3985632 sectors
atapiscsi0 at pciide0 channel 0 drive 1
scsibus0 at atapiscsi0: 2 targets, initiator 7
cd0 at scsibus0 targ 0 lun 0: <TEAC, CD-224E, 1.7A> ATAPI 5/cdrom removable
wd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 2
cd0(pciide0:0:1): using PIO mode 4, Ultra-DMA mode 2
pciide0: channel 1 ignored (disabled)
uhci0 at pci0 dev 7 function 2 "Intel 82440MX USB" rev 0x00: irq 15
piixpcib0 at pci0 dev 7 function 3 "Intel 82440MX Power" rev 0x00
fxp0 at pci0 dev 16 function 0 "Intel 8255x" rev 0x08, i82559: irq 9, address 00:00:0e:fd:d5:80
inphy0 at fxp0 phy 1: i82555 10/100 PHY, rev. 4
"AT&T/Lucent LTMODEM" rev 0x01 at pci0 dev 17 function 0 not configured
cbb0 at pci0 dev 19 function 0 "TI PCI1420 CardBus" rev 0x00: irq 9
cbb1 at pci0 dev 19 function 1 "TI PCI1420 CardBus" rev 0x00: irq 9
vga1 at pci0 dev 20 function 0 "Trident CYBER 9525" rev 0x49
wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
drm at vga1 unsupported
isa0 at pcib0
isadma0 at isa0
com0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo
pckbc0 at isa0 port 0x60/5
pckbd0 at pckbc0 (kbd slot)
pckbc0: using irq 1 for kbd slot
wskbd0 at pckbd0: console keyboard, using wsdisplay0
pcppi0 at isa0 port 0x61
midi0 at pcppi0: <PC speaker>
spkr0 at pcppi0
npx0 at isa0 port 0xf0/16: reported by CPUID; using exception 16
fdc0 at isa0 port 0x3f0/6 irq 6 drq 2
usb0 at uhci0: USB revision 1.0
uhub0 at usb0 "Intel UHCI root hub" rev 1.00/1.00 addr 1
isa at piixpcib0 not configured
cardslot0 at cbb0 slot 0 flags 0
cardbus0 at cardslot0: bus 1 device 0 cacheline 0x8, lattimer 0x20
pcmcia0 at cardslot0
cardslot1 at cbb1 slot 1 flags 0
cardbus1 at cardslot1: bus 2 device 0 cacheline 0x8, lattimer 0x20
pcmcia1 at cardslot1
biomask ffed netmask ffed ttymask ffff
mtrr: Pentium Pro MTRR support
uhidev0 at uhub0 port 1 configuration 1 interface 0 "B16_b_02 USB-PS/2 Optical Mouse" rev 2.00/98.02 addr 2
uhidev0: iclass 3/1
ums0 at uhidev0: 4 buttons, Z dir
wsmouse0 at ums0 mux 0
softraid0 at root
root on wd0a swap on wd0b dump on wd0b
auich0: measured ac97 link rate at 48000 Hz
wsmouse0 detached
ums0 detached
uhidev0 detached
uhidev0 at uhub0 port 1 configuration 1 interface 0 "B16_b_02 USB-PS/2 Optical Mouse" rev 2.00/98.02 addr 2
uhidev0: iclass 3/1
ums0 at uhidev0: 4 buttons, Z dir
wsmouse0 at ums0 mux 0
wsmouse0 detached
ums0 detached
uhidev0 detached
uhidev0 at uhub0 port 1 configuration 1 interface 0 "B16_b_02 USB-PS/2 Optical Mouse" rev 2.00/98.02 addr 2
uhidev0: iclass 3/1
ums0 at uhidev0: 4 buttons, Z dir
wsmouse0 at ums0 mux 0
wsmouse0 detached
ums0 detached
uhidev0 detached
uhidev0 at uhub0 port 1 configuration 1 interface 0 "B16_b_02 USB-PS/2 Optical Mouse" rev 2.00/98.02 addr 2
uhidev0: iclass 3/1
ums0 at uhidev0: 4 buttons, Z dir
wsmouse0 at ums0 mux 0
wsmouse0 detached
ums0 detached
uhidev0 detached
uhidev0 at uhub0 port 1 configuration 1 interface 0 "B16_b_02 USB-PS/2 Optical Mouse" rev 2.00/98.02 addr 2
uhidev0: iclass 3/1
ums0 at uhidev0: 4 buttons, Z dir
wsmouse0 at ums0 mux 0
wsmouse0 detached
ums0 detached
uhidev0 detached
umass0 at uhub0 port 1 configuration 1 interface 0 "Kingston DataTraveler 2.0" rev 2.00/2.00 addr 2
umass0: using SCSI over Bulk-Only
scsibus1 at umass0: 2 targets, initiator 0
sd0 at scsibus1 targ 1 lun 0: <Kingston, DataTraveler 2.0, 1.00> SCSI2 0/direct removable
sd0: 15384MB, 1961 cyl, 255 head, 63 sec, 512 bytes/sec, 31506432 sec total
sd0 detached
scsibus1 detached
umass0 detached
uhidev0 at uhub0 port 1 configuration 1 interface 0 "B16_b_02 USB-PS/2 Optical Mouse" rev 2.00/98.02 addr 2
uhidev0: iclass 3/1
ums0 at uhidev0: 4 buttons, Z dir
wsmouse0 at ums0 mux 0
wsmouse0 detached
ums0 detached
uhidev0 detached
uhub0: device problem, disabling port 1
uhidev0 at uhub0 port 1 configuration 1 interface 0 "B16_b_02 USB-PS/2 Optical Mouse" rev 2.00/98.02 addr 2
uhidev0: iclass 3/1
ums0 at uhidev0: 4 buttons, Z dir
wsmouse0 at ums0 mux 0
wsmouse0 detached
ums0 detached
uhidev0 detached
uhidev0 at uhub0 port 1 configuration 1 interface 0 "B16_b_02 USB-PS/2 Optical Mouse" rev 2.00/98.02 addr 2
uhidev0: iclass 3/1
ums0 at uhidev0: 4 buttons, Z dir
wsmouse0 at ums0 mux 0
wsmouse0 detached
ums0 detached
uhidev0 detached
umass0 at uhub0 port 1 configuration 1 interface 0 "Kingston DataTraveler 2.0" rev 2.00/2.00 addr 2
umass0: using SCSI over Bulk-Only
scsibus1 at umass0: 2 targets, initiator 0
sd0 at scsibus1 targ 1 lun 0: <Kingston, DataTraveler 2.0, 1.00> SCSI2 0/direct removable
sd0: 15384MB, 1961 cyl, 255 head, 63 sec, 512 bytes/sec, 31506432 sec total

------------------- dmesg stops -------------------

Reply via email to