How to read the input from the microphone?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Klakap
Member
Member
Posts: 299
Joined: Sat Mar 10, 2018 10:16 am

How to read the input from the microphone?

Post by Klakap »

Good day!
How do I read the input from the microphone? On osdev or on the forum, I found no instructions on how to make the support of the microphone. Please how do I do that?
Korona
Member
Member
Posts: 1000
Joined: Thu May 17, 2007 1:27 pm
Contact:

Re: How to read the input from the microphone?

Post by Korona »

You probably need a driver for Intel HD audio devices or for some USB audio class. (But I have no experience writing a driver for either of those.)
managarm: Microkernel-based OS capable of running a Wayland desktop (Discord: https://discord.gg/7WB6Ur3). My OS-dev projects: [mlibc: Portable C library for managarm, qword, Linux, Sigma, ...] [LAI: AML interpreter] [xbstrap: Build system for OS distributions].
User avatar
DavidCooper
Member
Member
Posts: 1150
Joined: Wed Oct 27, 2010 4:53 pm
Location: Scotland

Re: How to read the input from the microphone?

Post by DavidCooper »

On older machines you can use AC97 (although it's hard to support), but any machine modern enough to be worth programming for will likely use the more civilised Intel HD Audio instead, so your starting point should be to read this page of the Wiki: https://wiki.osdev.org/Intel_High_Definition_Audio. You may also need to read up on PCI (to find out what kind of sound card your machine supports). For USB microphones it's a lot more work as you also need to write USB drivers.
Help the people of Laos by liking - https://www.facebook.com/TheSBInitiative/?ref=py_c

MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: How to read the input from the microphone?

Post by Brendan »

Hi,
Klakap wrote:How do I read the input from the microphone?
Imagine that a computer is a tree of devices; with things like CPU and memory near the root node of the tree, and things like microphones at the end-nodes/leaves. Your question indicates that you're working from end nodes back to the root node; but it's better to work from the root node to the end nodes.

More specifically; it's better to do PCI bus enumeration, then choose a specific device in the list of unsupported devices that your software generated (e.g. maybe "vendor ID = 0x1002, device ID = 0xAA38", which corresponds to an "ATI RV710/730 HDMI Audio" device); then find the documentation for that specific PCI device and write a driver for it. While writing this driver you'll notice the device's documentation (hopefully) includes information about detecting and controlling attached devices (like speakers and microphones), so you'll naturally move one step closer to the end nodes in that part of the tree of devices.


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Klakap
Member
Member
Posts: 299
Joined: Sat Mar 10, 2018 10:16 am

Re: How to read the input from the microphone?

Post by Klakap »

Please how do I implement the PCI into my OS? On the page https://wiki.osdev.org/PCI I found no code that would have something to read PCI.
pat
Member
Member
Posts: 36
Joined: Tue Apr 03, 2018 2:44 pm
Libera.chat IRC: patv

Re: How to read the input from the microphone?

Post by pat »

Klakap wrote:Please how do I implement the PCI into my OS? On the page https://wiki.osdev.org/PCI I found no code that would have something to read PCI.
What are you having trouble with exactly? That page shows you exactly how to do PCI bus enumeration just like Brendan suggested. I mean there's even a function called pciConfigReadWord, which should answer "something to read PCI". The point of that article is to discover what devices are available. Then, like Brendan said, you can use the device id and vendor id to lookup the documentation for that specific thing, and then you make a driver for it.
Image is my operating system.

"...not because [it is] easy, but because [it is] hard; because that goal will serve to organize and measure the best of [my] energies and skills..."
Klakap
Member
Member
Posts: 299
Joined: Sat Mar 10, 2018 10:16 am

Re: How to read the input from the microphone?

Post by Klakap »

Please how do I program the sysOutLong and sysInLong?
Klakap
Member
Member
Posts: 299
Joined: Sat Mar 10, 2018 10:16 am

Re: How to read the input from the microphone?

Post by Klakap »

I have already resolve this problem, but I don't know where it is Header Type. Please tell me from where should I read Header Type.
//edit: Ups, I already noticed where it is Header Type :oops: .
Post Reply