okay this is a shot in the dark but do any #DOS folks know anything about where one would start with actually authoring PC speaker sound effects?
Sounds like I'm going to have to make my own sound editing utility for PC speaker. That's annoying but not unexpected. At least pico 8 gave me a model for how to think about it

In case you're wondering why I would bother with PC speaker sound when it's SO BAD, it's because I can't play soundblaster sounds without DMA and I can't do DMA without breaking my no assembly hacks rule

I might try using an OPL channel for sound effects but I don't know how that'll hold up for 30/35fps (since you can't buffer OPL commands) and also I don't know how much harder reserving one channel would make authoring music

@eniko there is a tracker software for pc speaker: Monotone. Not sure if that helps, but I found it pretty impressive, It has multi-voice and arpeggios 😍

https://www.youtube.com/watch?v=BF5SuKRF2CY

https://github.com/MobyGamer/MONOTONE

Monotone Tracker by Hornet

YouTube
@lea that's super cool, but alas doesn't really solve my problem XD
@eniko Does your no-asm rule apply to poking some opcodes into ram to make an IRQ handler? If not, you *could* do it all in QBASIC, given that PEEK/POKE let you write memory and registers, and you can, with algorithmic trial-&-error, DIM an array big/aligned enough for the handler and two buffers and get its address with VARSEG/VARPTR. It's semi-cheaty, but it's something someone with a PC that only had QBASIC in rom could have done. I just dunno how into the weeds you'd wanna get with this. 😉
@Felice i mean that's just embedding assembly opcodes as a string and using CALL ABSOLUTE but with extra steps, so nope, that's disallowed

@eniko Okay, that's what I meant when I asked the introductory question. Fair enough.

By the way, you really wouldn't want to use strings, at least not for resident asm functions. Strings can be relocated in garbage collection. I don't think arrays get relocated unless you resize them.

@eniko If it helps any, there is prescident for doing sound effects through the garbo pc speaker, tho I wonder how many cases these days even come with a PC speaker. Several of mine sure as shit haven't. o-o;

But yeah I grew up with PC speaker crap and I remember my dad putting a weird little utility into windows 3.11 that allowed the jank ass pc speaker to actually play .wav files out of it in windows. Like, actually play them. It was horrid of course, it all sounded like absolute garboleum and would only work for Windows, but it was pretty impressive regardless, turning somethign that was designed only to beep error codes and screech horrid sound at you into something that could play something RESEMBLIING actual sound.

@eniko

Not sure what you are looking for?

I had a lot of fun with this tool ages ago.

http://www.bluemoon.ee/history/scdos/index.html

Sound Club

@tobi82 utilities like that are good

@eniko I very very briefly looked into pc speaker music when I was trying to see how low bit you could go in the chiptune scene around 2011.

The tracker MONOTONE is written in pascal, which is a little fiddly, but it does pc speaker sounds in a slightly hardware-agnostic way.

https://github.com/MobyGamer/MONOTONE/tree/master

The source for the speaker output is here:

https://github.com/MobyGamer/MONOTONE/blob/master/MTSRC/MT_OUTP.PAS

I am not good at pascal, but my general understanding is that it reads the BIOS clock, waits for it to tick over once, then sends the note as a set frequency number to the memory address of the pc speaker. Then, on the next tick, it checks memory to see if it needs to send that same number to the speaker again or if it needs to set the speaker to a frequency that's impossible for it to make which results in it not making any noise at all.

@eniko depends on how complex you trying to get, you can play any sound on a pc speaker, just need to resample it to 1bit, so technically any sample editor will do. if you want more advanced multi-voice engines there is monotome https://github.com/MobyGamer/MONOTONE and shiru's PCSPE https://shiru.untergrund.net/software.shtml to play around with.
@eniko If you're talking old school games, its usually just frequency sweeps or noise n such. or are you looking for the technical side?
@discatte im mostly wondering about like, tools that would help. But also information on techniques and such
@eniko Your best bet is old programming bbs dumps like https://files.mpoli.fi/software/PROGRAMM/C/ (just look for effect/sound)
Metropoli BBS - C:\SOFTWARE\PROGRAMM\C

@eniko It's more about how I went about managing the playback, but it turns out most of my PIT-related crimes that I was being coy about were also related to commanding the PC speaker, from background processing of normal tones (which I think would be QBASIC friendly) to 7-bit PWM digital playback (which would not).

I wrote it up at the time with sample code, so, spoilers ahoy:

https://bumbershootsoft.wordpress.com/2016/12/10/beyond-beep-boop-mastering-the-pc-speaker/

The PWM stuff is definitely one of the "weirdly clean for something accidental" things.

Beyond Beep-Boop: Mastering the PC Speaker

I had done a fair amount with DOS as a youth, but I’d never really gotten sound to work. Let’s close that gap. This is a challenge because music and sound are very much about precise ti…

Bumbershoot Software
@eniko I couldn't find a tool, so I ended up:
- writing a parser for Apogee IFS format PC speaker audio
- seeing what kind of number patterns were used for each kind of sound
- made some Python scripts to generate numbers
- Lua hotloaded the numbers into my engine with to hear them
@moralrecordings I'm kinda limited to qbasic's PLAY command so I don't think I can do that >_>
@eniko I believe QBASIC supports OUT for writing to the hardware ports, you could write some code that directly programs PIT2?

https://github.com/moralrecordings/perentie/blob/main/src/dos.c#L489
https://github.com/moralrecordings/perentie/blob/main/src/pcspeak.c
perentie/src/dos.c at main · moralrecordings/perentie

Lua-based adventure game engine for DOS. Contribute to moralrecordings/perentie development by creating an account on GitHub.

GitHub
@moralrecordings it might be possible to reprogram PIT channel 2 but i can't get interrupt requests
@eniko ahhh apologies, I forgot that the default timer in DOS is 18.2Hz. You need at least 140Hz for IFS... wonder how much of the QBASIC internals would explode on impact if the PIT0 clock got changed

@moralrecordings i'm afraid of trying, so i don't know :'D

but testing in dosbox tells me i can get 57 notes per second out of the PLAY command which is enough for crude sound effects

speaking of 18.2Hz you wouldn't believe the day i had trying to lock framerate to 30/35 for slower machines

@eniko Solidarity, I believe it. It was plenty of a struggle to get the screen to draw on real VGA without tearing, let alone adding a fixed half framerate mode in QBASIC.

@moralrecordings well one thing i learned is that everyone is wrong about the raw channel0 PIT value when set to defaults. everywhere claims it goes 65535 to 0 then fires an irq when it underflows, and that's what sets the 18.2Hz clock

but it actually underflows *twice* per clock because it's a square wave and the irq only fires on the rising edge

@eniko @moralrecordings

Ah now I get it, you asked for “internal” speaker.

I remember it was straight forward in Turbo Pascal. Why are you restricted to basic?

@tobi82 @moralrecordings it doesn't enjoy when you reprogram the PIT