gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > No Microphone Input Example?(libnds)

#154118 - PlagueSpark - Fri Apr 11, 2008 3:31 pm

I'm using libnds +VC2005 Express

As docs/manuals are printed - microphone is managed by arm7 (unacssasable by arm9) even found that function in arm7

I know that palib gives acess to function that returns the unsigned short int value of microphone input.

So topic is: Is there any code samples(/project templates) that shows how to handle microphone input by just libnds???

#154125 - silent_code - Fri Apr 11, 2008 7:18 pm

hi!

i can't remember if there's an example that comes with libnds, but i remember that there was one on chris double's (?) page.
also, i don't know if this helps or not, but you can always check gbatek for accurate information!

happy coding!

#154131 - PlagueSpark - Fri Apr 11, 2008 8:19 pm

There is no microphone example that comes with libnds

It seems that I should use "combined template" instead of "arm9 template"

#154135 - PlagueSpark - Fri Apr 11, 2008 9:16 pm

Sorry for Double-Posting!

I found cool and quick solution!

All need is to modificate arm7 core file for sending MIC_ReadData() instead of pressure power on ordinate :)

And ofcource adding MIC_ON() on ARM7's start up

Pressure values are not much being used (I believe)

So every time touchscreen is read - he brings microphone data on it's .px of data structure

#154163 - silent_code - Sat Apr 12, 2008 2:16 am

i guess this is a "dirty" way of doing it. well, i haven't used the microphone, yet, so i don't know.
btw: here is the tutorial i mentioned before. beware, it's quite old!

have fun!

#154167 - 0xtob - Sat Apr 12, 2008 2:49 am

Here is a simple microphone example that shows how to trigger recording from the arm9 and has much higher quality than libnds's integrated microphone functions. I'm not sure if it still compiles, but you'll get the idea. This program uses a shared memory command passing interface by dekutree. A cleaner way of passing commands between the CPUs would use the FIFO, but for my software the shared memory approach has proven very reliable.
_________________
http://blog.dev-scene.com/0xtob | http://nitrotracker.tobw.net | http://dsmi.tobw.net

#154175 - PlagueSpark - Sat Apr 12, 2008 9:12 am

I had read the "old" microphone example before doing mic code realisation by mine.

All I was needed was the current microfone input (detecting blowing), not a recorded fragment.

#154182 - silent_code - Sat Apr 12, 2008 12:42 pm

ah, then all you need is a threshold value.
you simply fill a small buffer with recorded audio and iterate over it to check for that. then it' sufficient to return a single int. you're right. :^)

btw: welcome to the forum. :^D

#154183 - PlagueSpark - Sat Apr 12, 2008 1:47 pm

silent_code wrote:
ah, then all you need is a threshold value.
you simply fill a small buffer with recorded audio and iterate over it to check for that. then it' sufficient to return a single int. you're right. :^)

Why check some filled buffer? On each touchscreen check my solution already sends current byte of microphone input. Totaly no need to iterate something. So for each frame I got mic byte to make something out of this.
To do this is only needed to adjust two strings in libnds arm7 template

Code:

   IPC->touchX         = x;
   IPC->touchY         = y;
   IPC->touchXpx      = MIC_ReadData();// HERE!
   IPC->touchYpx      = ypx;
   IPC->touchZ1      = z1;
   IPC->touchZ2      = z2;
   IPC->buttons      = but;


Code:

   irqInit();
   
   MIC_On();// AND HERE :)

   initClockIRQ();

   SetYtrigger(80);
   irqSet(IRQ_VCOUNT, VcountHandler);
   irqSet(IRQ_VBLANK, VblankHandler);

No need for some cpu and memory consuming operations

Only disadvance that pressure value by x is missed, but it the Y pressure value can act as X also if your application need it (stylus is round also).

This is a pity that there is not much homebrew taking advantage of microphone :(

#154203 - silent_code - Sat Apr 12, 2008 9:45 pm

oh, i was just thinking, it might be better to use several values to ensure consistency (in that case you normally wouldn't count too short inputs), but yes, your approach is also valid. 60 samples per second are *quite* ok. ;^)
can't you extend the structure that holds the values to add your mircophone value?

#154238 - PlagueSpark - Sun Apr 13, 2008 9:29 am

silent_code wrote:
can't you extend the structure that holds the values to add your mircophone value?

I'm not sure what you want to say 8-/
Why is to sum something?
The program on arm9 recieves all needed data to work with microphone.
So u8 (is native format data of microphone) is totaly enogh to check if the microphone catches blowing or scream :) at current frame
There is no need to code something more on arm7.
For games/programs that needs microphone as "another action button" my solution works supreme :)

#154247 - wintermute - Sun Apr 13, 2008 1:15 pm

Any code that uses the IPC struct will fail in future updates of libnds, it's best if you avoid custom arm7 code for now.
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog