Home Events! Entrance Everyone Wiki Search Login Register

Welcome, Guest. Please login or register. - Thinking of joining the forum??
November 22, 2024 - @504.84 (what is this?)
Forum activity rating: Three Stars Posts: 35/1k.beats Unread Topics | Unread Replies | My Stuff | Random Topic | Recent Posts    Start New Topic
News: :happy: Open the all windows! Your mind needs storms and air! :happy:

+  MelonLand Forum
|-+  World Wild Web
| |-+  ☞ ∙ Life on the Web
| | |-+  ⛽︎ ∙ Technology & Archiving
| | | |-+  Writing a sound server based on ALSA


« previous next »
Pages: [1] Print
Author Topic: Writing a sound server based on ALSA  (Read 564 times)
Marcellus
Casual Poster ⚓︎
*


Rance Baise Ouais !!

⛺︎ My Room
iMood: Marcellus

View Profile WWW

Joined 2023!
« on: January 13, 2024 @930.61 »

So I have had this project in mind for a few months now, I'd like to write my own sound server. I am thinking of making a simplified version of pulseaudio, from scratch, using the Advanced Linux Sound Architecture (ALSA) library API.
I understand I might be stepping into a very deep and scarsely documented domain, but I want to try my best and at least have the program interact with sound devices (like capture input from them and send audio playback data to them).

At the moment I am making research, and gathering as much information as I can. Here's a list of what I have found so far:
- The ALSA library API documentation
- Links to some guides about the library API
- A very basic example of using the API
- A pretty decent guide explaining some core concepts about audio handling although they are using a Windows backend lib so this isn't exactly what I'm looking for
- The PulseAudio documentation, this might prove to be useful
- This code I found a while ago, will have to look into it

I'd gladly accept any input or advice, if you have any link or guide or whatever that could guide me :ozwomp:
« Last Edit: February 06, 2024 @52.41 by Marcellus » Logged

"Sometimes I create feelings in others that they themselves don't understand."
- Flash McQueen
Melooon
Hero Member ⚓︎
*****


So many stars!

⛺︎ My Room
SpaceHey: Friend Me!
StatusCafe: melon
iMood: Melonking
Itch.io: My Games

View Profile WWW

Thanks for being rad!a puppy for your travelsAlways My PalFirst 1000 Members!spring 2023!Squirtle!!!!MIDI WarriorMIDI Warrior1234 Posts!OzspeckCool Dude AwardRising Star of the Web AwardMessage BuddyPocket Icelogist!OG! Joined 2021!...
« Reply #1 on: January 13, 2024 @943.23 »

Interesting; so this is like the audio mixing doodad you get in Windows?

I know it's depressingly practical to ask, but why do you wanna do this when there are existing sound servers? Is there something different you'd like to add? I'm always an advocate of the idea that if you're gonna invest a lot of time and effort in a project (and this sounds like a LOT of time and effort) it should produce something that in some way has never existed before.

So, I'm curious what the goal is for you? And if you're doing it as a learning exercise, I would say shake it up a bit, don't just clone an existing thing; make something weird and arty like a sound-inverting on-the-fly bitrate control system. I dunno if anyone needs that, but maybe they just don't know yet  :ok:

Plus if you make something utterly unique, it will always be the best of its kind in the world, so you'll feel like a pioneer!
Logged


everything lost will be recovered, when you drift into the arms of the undiscovered
m1k3
Jr. Member
**


⛺︎ My Room
XMPP: Chat!

View Profile WWW

Joined 2024!
« Reply #2 on: January 14, 2024 @190.42 »

I'd be interested to know too as PipeWire seems to be the preferred replacement for ALSA and PulseAudio on Linux. At the moment I'm still using ALSA though.
Logged
Marcellus
Casual Poster ⚓︎
*


Rance Baise Ouais !!

⛺︎ My Room
iMood: Marcellus

View Profile WWW

Joined 2023!
« Reply #3 on: January 14, 2024 @546.28 »

Interesting; so this is like the audio mixing doodad you get in Windows?

Kinda, the ALSA lib API allows you to connect to a sound card (so any audio interface, like a physical external sound card, or the builtin sound card there may be in your laptop), read some analog data and convert it to digital using a defined sample rate, audio buffer size and all that and write some digital data by converting it to analog using the same parameters. (This is what I think I understood at least)

So, I'm curious what the goal is for you? And if you're doing it as a learning exercise, I would say shake it up a bit, don't just clone an existing thing;

My goal is pretty much to learn how it works, but also to have a project for the coming months. I'll start by making something that works, and then I'll tweak it to make it mine. If it turns out to be doable, I might make it a guide for the E-Zine !

I'd be interested to know too as PipeWire seems to be the preferred replacement for ALSA and PulseAudio on Linux. At the moment I'm still using ALSA though.

From what I understand ALSA is the layer just above hardware, and it implies dealing with device drivers so I'm not touching that. I found this chart describing the general way this works.
Logged

"Sometimes I create feelings in others that they themselves don't understand."
- Flash McQueen
m1k3
Jr. Member
**


⛺︎ My Room
XMPP: Chat!

View Profile WWW

Joined 2024!
« Reply #4 on: January 14, 2024 @861.59 »

From what I understand ALSA is the layer just above hardware, and it implies dealing with device drivers so I'm not touching that. I found this chart describing the general way this works.

Ah, you're absolutely right. This was an opportunity to learn more about this because I've taken for granted the ALSA tools in FatDog64 (Linux distro I use). Thanks for the link - that's a good visual!

If you want a starting point or some inspiration, one of the developers of FatDog created his own tool to replace PulseAudio and interact with snd-aloop (ALSA Loopback module) directly. He used shell scripts and YAD (yet another dialog) for the GUI.

This is what it looks like when I go to the default sound card wizard in FD:


After I select aloopd, I can then start configuring it by selecting options and output routing. I typically always use software volume control and the preamp since the speakers on my old laptop aren't very loud.











Finally, it restarts the aloopd server with the new configuration. As he shows on his blog, it works like this:

Quote
The entire setup is conceptually simple:
- use snd-aloop to create a virtual soundcard and make it as the default output.
- run alsaloop, which reads audio from this virtual soundcard, and push it out the actual soundcard.

So the audio routing becomes like this:
app --> loopback virtual soundcard --> alsaloop --> actual soundcard.

Logged
Marcellus
Casual Poster ⚓︎
*


Rance Baise Ouais !!

⛺︎ My Room
iMood: Marcellus

View Profile WWW

Joined 2023!
« Reply #5 on: January 16, 2024 @962.69 »


If you want a starting point or some inspiration, one of the developers of FatDog created his own tool to replace PulseAudio and interact with snd-aloop (ALSA Loopback module) directly.


Wow thanks, this looks like an excellent starting point !!
Logged

"Sometimes I create feelings in others that they themselves don't understand."
- Flash McQueen
Pages: [1] Print 
« previous next »
 

Vaguely similar topics! (3)

Art based on my friends dream

Started by DojidaveBoard ➶ ∙ Art Gallery

Replies: 1
Views: 1489
Last post April 06, 2022 @976.28
by cinni
Pages & sites with sound

Started by DJoftheCovenBoard ✁ ∙ Web Crafting

Replies: 8
Views: 1615
Last post May 03, 2023 @643.34
by Skykristal
Any web-based games??

Started by syx (dead)Board ♖ ∙ Video Games

Replies: 7
Views: 1680
Last post January 03, 2023 @238.67
by worldwidewar

Melonking.Net © Always and ever was! SMF 2.0.19 | SMF © 2021, Simple Machines | Terms and Policies Forum Guide | Rules | RSS | WAP | Mobile


MelonLand Badges and Other Melon Sites!

MelonLand Project! Visit the MelonLand Forum! Support the Forum
Visit Melonking.Net! Visit the Gif Gallery! Pixel Sea TamaNOTchi