Close

Project log 7 (15.07.2023) - Refactoring, Serial Port, Suffering and a new Audio System

A project log for MaslOS

A custom os made from almost scratch.

marcelMarcel 07/15/2023 at 18:200 Comments

Hoi ppl. 

It has been like 3 months but I haven't died yet!

School has been a lot of pain so I didn't work much on the OS for the last few months.

Buuuuuut recently I did!

I started doing some stuff on like a midi format (which i then scrapped, but we'll come to that later)

Soooo i refactored some stuff in the Github Repo and the code itself.

Then I added support for the serial interface!

(The serial thingy works in QEMU and on actual hardware with a serial port)

Slight problemo: I have 2 PCs for testing: 1 has a serial port but I can't put expansion cards in it and one has no serial port but allows for expansion cards which I want for sound cards and later on maybe networking or something idfk.

Well the solution is simple enough: buy a pci serial card! Which is what I did but trying to get it to work has given me a lot of pain. So I've currently stopped trying to get it to work. For now atleast. (If anyone is experienced in writing drivers for PCI serial expansion cards and especially the "PCIE to Dual Serial Ports and Printer Port Chip CH382" please let me know!!!!!!)

Also with the serial interface comes more debugging possibilities.

If the os now gets into a kernel panic, it will actually send the stack trace to the serial port and launch an interactive shell, where you can even restart the renderloop to possibly recover and save stuff! Also the OS reserves like 16MB of memory for safety reasons when it runs out of mem or the heap gets corrupted. And in total there are 4 different crash commands in the os now.

And for the big thing of this update MaslOS now has an actually good sound system. I designed it from scratch, mostly because i was too lazy to look at how other operating systems do sound stuff. Also the OS supports the PC-Speaker, AC97, (and it did kinda support SB16 for a bit but then I found out about AC97 and decided to use that instead).

Basically my Audiosystem allows for audio sources and destinations which have an audio buffer. That buffer has a specific sample rate, sample count, bits per sample and channel count. (Every source and destination has a buffer, where the stuff can be customized)

And how my system basically works is that destinations steal the data from connected sources to replenish their buffer. Then they can play it until they are done and then they'll request more data. This can be a whole chain with multiple sources in between and it allows for destinations to have multiple sources connected at once without any issues. Technically you can also make a splitter source/destination thingy but that might have issues since the source is not sending the data so if a destination lags or is somehow slower than each destination could be affected, but it can be made, just i haven't yet bc laziness ig)

So yeah, I think i might be doing it in like reverse order than how most systems work, but imo I think it works well and the system does make sense. Also the neat thing is, that the audio system actually natively supports lets say a 44Khz 16 bit stereo source playing to a 20khz 8 bit mono speaker and even an 8 bit mono source playing to a 16 bit stereo or mono or whatever destination. basically the audio system converts the buffers on the fly so you dont actually have to do anything, except for using the correct buffer settings.

The OS also has a default input and output device. tho the input device is null since i dont really have any microphones hooked up or taken a look at the ac97 microphone thingy. also the default output device is the pc speaker, unless MaslOS finds an AC97 card and it will set that as the default output device!

Also I did actually buy an AC97 sound card for my testing PC but that's not quite working yet. (It's in the pile of working in the VM but not on real hardware, like the PCI serial card and the AHCI Driver smh)

Also I have added a music player which can play wav files!

There is a bad apple music file on the main virtual disk created on boot. (the wav is like 20MB even converted to a 30KHz Mono Wav file smh)

I might add like an mp3 player someday. But the more fun thing would be to make an actual midi player/synth that just opens normal mid or midi files. I also found some sound samples but not for now prolly. And that's also why I stopped working on the MBAF and the custom midi format.

One thing which I do need to add and want to add is first of all a slider component. I want that in the music player to like scrub around and see the progress and i want it bc i wanna make a volume control (for the music player and for all devices globally)

I also want to make a whole sound config menu thing where ppl can select the default devices, change properties and maybe even reconnect sound sources. Like imagine you can just change the destination speaker of an app while its running as an OS setting. Would be pretty neat.

I also want to add like a screen magnifier because thats cool. 

That's about it for the post. 

One thing though: I will probably be suffering for a while refactoring and rewriting parts of the OS. 

It has been more than a year since I've started this journey and I have learned lots of stuff during this time. I now know how I could improve a lot of code and I need to refactor the structure. (The OS literally has 3 different boot methods which all depend on each other and there is a lot of messy stuff)

So that will prolly take some time.

Stuff I'm currently working on / planning to do: (mostly the same)

 - Refactor a lot of OS stuff

 - Add Sliders

 - Add Sound Control and Device Controls

 - Add Screen Magnifier

 - Add Midi player maybe

Stuff which is far away on my Todo:

 - Fixing AHCI Driver, PCI Serial Card and AC97 Card

 - Making Paint

 - Improving Notepad

- Improving the Image Viewer

- Making a GUI Taskmanager

- Adding The Debug Ram Viewer to the Start Menu

- Maybe making a Debug Ram Image Viewer- Improving Tetris

Discussions