Image Map Image Map
Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 25

Thread: PC Speaker (Square Wave) Sound Effects

  1. #11

    Default

    Samples can be surprisingly low bit rate - JPM's Impact fruit machines use a rate <1kHz IIRC

  2. #12
    Join Date
    Aug 2006
    Location
    Chicagoland, Illinois, USA
    Posts
    4,028
    Blog Entries
    1

    Default

    Not 1KHz (sample rate 2KHz), that's way too low. But I wouldn't be surprised if they used 6-8KHz for sound effects or male speech.

    If this is the system we're talking about: https://www.youtube.com/watch?v=93Mx-GYQ7NY ...then that sounds like 6-8 KHz sample rate to my ears.
    Offering a bounty for:
    - Music Construction Set, IBM Music Feature edition (has red sticker on front stating IBM Music Feature)
    - Any very old/ugly IBM joystick (such as the Franklin JS-123)

  3. #13

    Default

    All the samples are in a 512KB EEPROM. That is an impact machine, maybe you're right!

  4. #14
    Join Date
    Aug 2006
    Location
    Chicagoland, Illinois, USA
    Posts
    4,028
    Blog Entries
    1

    Default

    The samples could be compressed using a simple scheme too. Hard to tell without seeing the contents of the EEPROM.

    Edit: After half an hour of sleuthing, finding the speech ROM, and looking at specs, I've determined the JPM Impact "fruit machines" uses an NEC µPD7759 ADPCM speech synthesis chip. The sample data seems to support that as the data appears packed into nybbles and requires decoding. The chip decompresses 4-bit input to 9-bit output at rates of 5, 6, or 8KHz, so that explains the audio quality at that size. (For more details on how to decompress the data, see upd7759.cpp in the MAME source code.)
    Last edited by Trixter; January 25th, 2017 at 05:18 PM.
    Offering a bounty for:
    - Music Construction Set, IBM Music Feature edition (has red sticker on front stating IBM Music Feature)
    - Any very old/ugly IBM joystick (such as the Franklin JS-123)

  5. #15

    Default

    Nice work Jim!

  6. #16

    Default

    Quote Originally Posted by mangis View Post
    This is the main sound player source code for MagiDuck in case it helps.

    Code:
    aSoundPlay PROC
      ;
      ; Call this once per frame.
      ;
      ; Play a note from the sound queue,
      ; advance queue pointer by one.
      ; Clear current note after playing it.
      ;
      ; A note will keep playing until a Note-OFF is found in the queue.
      ;
      ; The queue is basically a circular buffer.
      ; A note is a lookup table offset. The lookup table stores the actual frequencies.
      ; 
      xor  bx, bx
      mov  bl, soundPos
      xor  ax, ax
      mov  al, soundQueue[bx]
      mov  soundQueue[bx], 0
      cmp  ax, 1
      jb   noPlay
      ;
      ; Get frequency from LUT
      ;
      shl  ax, 1
      xchg bx, ax
      mov  ax, freqData[bx]
      xchg al, bl
      ;
      ; Set frequency and enable speaker
      ;
      cli
      mov  al,  0B6h
      out  43h, al
      xchg al, bl
      out  42h, al
      xchg al, ah
      out  42h, al
      mov  al, soundOn
      out  61h, al
      sti
      jmp  exitPlay
      ;
      ; Note OFF
      ;
      noPlay: 
      cli
      mov  al, soundOff
      out  61h, al
      sti
      ;
      ; Advance sound queue pointer
      ;
      exitPlay:
      inc  soundPos
      and  soundPos, 63
      
      retf
    aSoundPlay ENDP
    Just for the fun of it I optimized this code slightly (this is in NASM format BTW);
    Code:
    aSoundPlay:
    	mov	al, [soundPos]
    	cbw
    	mov	bx, ax
    	inc	ax
    	and	al, 63
    	mov	[soundPos], al
    	mov	al, ah
    	xchg	al, [bx+soundQueue]
    	shl	ax, 1
    	jz	SHORT .noPlay
    	xchg	bx, ax
    	mov	bx, [bx+freqData]
    
    	mov	al, 0B6h
    	cli
    	out	43h, al
    	mov	al, bl
    	out	42h, al
    	mov	al, bh
    	out	42h, al
    	mov	al, soundOn
    	out	61h, al
    	sti
    	retf
    
    .noPlay:
    	mov	al, soundOff
    	out	61h, al
    	retf
    Looking for a cache card for the "ICL ErgoPRO C4/66d V"

  7. #17

    Default

    Thank you Krille for the Magic Duck stuff. Could you tell me offhand how fast the frame rate is when you run aSoundPlay?

    I was just looking at the Beep() function in the Windows API and noticed that its maximum rate is 1 millisecond. That's surely too slow for PWM but fast enough to do Magic-Duck-ish sound effects.

    What's interesting about Beep() is that it apparently utilizes the PIT (the AT / 8254 version) directly. I thought it might use some crazy virtualized thing based on Windows internals. This made me wonder if there's a way in Windows to access the PC Speaker more directly to allow for PWM. I know that ports are off limits except to device drivers but is there a backdoor somewhere?

    (P.S. -- This is for my own insatiable curiosity; I have no practical reason for wanting to talk to the PC Speaker directly on Windows. I'm not even sure my Windows 10 laptop has a real PC Speaker within it. And of course if it's a piezoelectric speaker then could it even handle PWM?)

  8. #18
    Join Date
    Dec 2014
    Location
    The Netherlands
    Posts
    1,474

    Default

    Quote Originally Posted by neilobremski View Post
    I know that ports are off limits except to device drivers but is there a backdoor somewhere?
    Not that I know of... you'd need to interface with the timer directly to do 'conventional' PWM via channel 2... Or you'd need to interface with the PPI directly to toggle the speaker on/off manually for an alternative way to do PWM.
    Not to mention that accurate timing and a multitasking OS don't quite mix, so you'd want to do this from a driver anyway, to get the timing accurate enough.

    For older versions of Windows (3.x, possibly 9x?) there actually was a PC speaker driver available, and it was capable of playing digital audio via PWM.
    Edit: Apparently it came with Microsoft's 'Speak.exe': http://download.cnet.com/Microsoft-W...3_4-19900.html

  9. #19

    Default

    Quote Originally Posted by neilobremski View Post
    (P.S. -- This is for my own insatiable curiosity; I have no practical reason for wanting to talk to the PC Speaker directly on Windows. I'm not even sure my Windows 10 laptop has a real PC Speaker within it. And of course if it's a piezoelectric speaker then could it even handle PWM?)
    Piezo beepers generate unintelligible junk when software tries to do PWM output with them. However, most modern laptops that I'm aware of (since at least 2005 or so) don't actually have a separate beeper device, but route the sound through the main audio output, which goes to something at least vaguely resembling a proper speaker, so I imagine that, should you actually succeed in getting access to it on your laptop (maybe boot FreeDOS off a USB stick or something?) you'd probably get intelligible output (well, by the standards of PC speaker PWM output, anyway...)
    Computers: Amiga 1200, DEC VAXStation 4000/60, DEC MicroPDP-11/73
    Synthesizers: Roland JX-10/SH-09/HS-80/MT-32/D-50, Yamaha DX7-II/V50/TX7/TG33/FB-01, Korg MS-20 Mini/ARP Odyssey/DW-8000/M1, Ensoniq SQ-80, E-mu Emax HD/Proteus-2, Casio CZ-5000, Moog Satellite, Sequential Circuits Prophet-600
    "'Legacy code' often differs from its suggested alternative by actually working and scaling." - Bjarne Stroustrup

  10. #20
    Join Date
    Dec 2014
    Location
    The Netherlands
    Posts
    1,474

    Default

    Quote Originally Posted by commodorejohn View Post
    Piezo beepers generate unintelligible junk when software tries to do PWM output with them.
    This seems to be a common myth. In practice however, PWM generally works acceptably on piezo speakers. No, you won't get high-quality audio (then again, we're talking PC speaker here), but they can certainly produce recognizable audio.
    I have two 8088 clones with piezos on them, I could do some recordings.

Page 2 of 3 FirstFirst 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •