#47590 - NEiM0D - Mon Jul 11, 2005 4:38 am
Hi,
I've figured out how the microphone works.
Here is some sourcecode (uses my own defines and such, from my site DSTek (http://neimod.com/dstek/)):
http://www.rafb.net/paste/results/M1ZT3a93.html
Can someone make an ndslib compatible version perhaps?
I don't like ndslib that much myself, but I gather alot of people use it.
Oh yes, there's a microphone gain control register too, an update should follow.
Cheers.
#47592 - Volta - Mon Jul 11, 2005 5:14 am
two thumbs up! :D
#47598 - rize - Mon Jul 11, 2005 5:53 am
Is the recording/playback supposed to be that full of static?
nice job btw
#47599 - MrAdults - Mon Jul 11, 2005 6:27 am
Great to see someone got this up and running, I've been waiting for it. Haven't tried it yet, but looking at it I would note that (0^128)==128 (as an example), and that will be treated as noise on an 8-bit sound channel, which would be producing static. (the ds sound buffer should be read as unsigned, so that will not wrap)
Edit: tested this out this morning, sounds fine on my hardware.
-Rich
Last edited by MrAdults on Mon Jul 11, 2005 2:39 pm; edited 1 time in total
#47612 - doublec - Mon Jul 11, 2005 11:30 am
#47621 - Chetic - Mon Jul 11, 2005 1:52 pm
Great job, Neimod!
Now we pretty much just have Wifi left, eh? ;)
_________________
Packin':
Grey DS with FlashMe v7
1Gbit XG2T 2005 (Neoflash compatible)
GBAMP, Supercard CF, 512Mb Magic Key 3 and EZFA 256Mbit
#47624 - Spaceface - Mon Jul 11, 2005 3:05 pm
a bit offtopic.. how does the DS in for instance wario ware detects it that you're blowing, and not just making a shitload of noise.. frequency's?
#47625 - duencil - Mon Jul 11, 2005 3:17 pm
MrAdults wrote: |
Great to see someone got this up and running, I've been waiting for it. Haven't tried it yet, but looking at it I would note that (0^128)==128 (as an example), and that will be treated as noise on an 8-bit sound channel, which would be producing static. (the ds sound buffer should be read as unsigned, so that will not wrap)
Edit: tested this out this morning, sounds fine on my hardware.
-Rich |
doublec's libnds compatible remake uses an unsigned sound buffer, but keeps the ^0x80 for signed conversion. I?ve tried with and without the signed conversion for recording voice and music, and I can't tell which is correct. Anyone have a better ear?
#47627 - lambi1982 - Mon Jul 11, 2005 3:25 pm
Spaceface
Quote: |
a bit offtopic.. how does the DS in for instance wario ware detects it that you're blowing, and not just making a shitload of noise.. frequency's?
|
The noise is what is looks for, when you blow into a microphone it creates a very loud noise, it does not register pressure of any kind.
try it out on a regular mic hooked to a stereo, thats all nothing special.
Now to create voice to text on the DS :)
_________________
Who, Me?
#47652 - doublec - Mon Jul 11, 2005 11:24 pm
Playing around with signed/unsigned and the bit shifts in the values from MIC_GetData8 results in variations of loud recording but distorted vs quiet with a little bit of static. I'm sure there's a sweet spot somewhere that gives good volume recording with no static. I'm not knowledgable enough about sound myself to work out what the problem is though.
#47718 - assassda - Tue Jul 12, 2005 7:20 pm
Quote: |
Now to create voice to text on the DS :) |
or at least voice chat first like dsspeak
#48017 - lambi1982 - Sat Jul 16, 2005 5:51 am
voice chat with what? there isnt any code for a DS to DS connection YET.....( homebew ) I just thought it would be nice to input your own text.
Dont think that would be hard, just replace the text that is on the top screen and add a text box ;)
I will shut up now......... ( As he walks quietly into the shadows )
_________________
Who, Me?
#48022 - TJ - Sat Jul 16, 2005 7:02 am
Well, you could start working on the interface, audio I/O, and real-time encoding/compression.
By the time you had all the bugs worked out on that, there would probably be some useable wireless code.
#48044 - tepples - Sat Jul 16, 2005 2:21 pm
I can imagine that something dead simple like 8ad (a form of ADPCM) would be sufficient for compressing the audio. An 8ad data stream at 8 kHz sample rate (telephone quality) is 32 kbps (half duplex); a pair of streams (one in, one out) is 64 kbps. Compare that to the 2000 kbps stated capacity of a Ni-Fi channel.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#69917 - knight0fdragon - Fri Feb 03, 2006 12:01 am
Has anyone got this to work with the new libnds??? Do i have to override the arm7 to use the StartRecording and Stop recording functions?? I can not find another way to actually access these functions from the arm9
_________________
http://www.myspace.com/knight0fdragonds
MK DS FC: Dragon 330772 075464
AC WW FC: Anthony SamsClub 1933-3433-9458
MPFH: Dragon 0215 4231 1206
#71136 - knight0fdragon - Fri Feb 10, 2006 4:09 pm
looking at the mic source, it seams that if i take out the ^ 80 in ProcessMicrophoneTimerIRQ() functuins MixRead(), it makes it louder but does not clear the distortion
_________________
http://www.myspace.com/knight0fdragonds
MK DS FC: Dragon 330772 075464
AC WW FC: Anthony SamsClub 1933-3433-9458
MPFH: Dragon 0215 4231 1206
#71178 - tepples - Fri Feb 10, 2006 8:58 pm
Try making an oscilloscope program. Read the microphone's waveform buffer and draw it to a bitmapped background, one sample per column.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#71220 - knight0fdragon - Sat Feb 11, 2006 3:40 am
yes i will do that good idea, btw, ^80 doesnt go from signed to unsigned...... or does the DS not use 2s compliment to go from positive to negative? IE 1 = 01h and -1 = FFh
_________________
http://www.myspace.com/knight0fdragonds
MK DS FC: Dragon 330772 075464
AC WW FC: Anthony SamsClub 1933-3433-9458
MPFH: Dragon 0215 4231 1206
#71280 - tepples - Sat Feb 11, 2006 3:51 pm
To toggle 8-bit data between signed and unsigned, use ^ 0x80. (Not 80 which means 0x50, 0x80 which means 128.)
To toggle 16-bit data between signed and unsigned, use ^ 0x8000.
Seriously, making an o-scope will make it easier for you to diagnose audio capture format problems.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#71291 - knight0fdragon - Sat Feb 11, 2006 5:49 pm
well i was refering to hex with the 80, but why would the last bit affect how loud it is if it was to be signed and unsigned, how would the volume be affected
_________________
http://www.myspace.com/knight0fdragonds
MK DS FC: Dragon 330772 075464
AC WW FC: Anthony SamsClub 1933-3433-9458
MPFH: Dragon 0215 4231 1206
#71350 - 0xtob - Sun Feb 12, 2006 12:51 am
I spent the evening figuring out why the mic quality in the Sampling Keyboard sucked that much and found out several reasons:
- The gain register was not set (seems to default to the lowest gain)
- The arm7 vblank handler disturbed the recording, causing low-freq distorsion
- Sampling rate was only 16khz
- Sampling resolution was only 8 bit (12 is possible)
Here's a demo that has all the above issues fixed, including source code: hifimic.zip
The recording is much clearer and louder than with the original (doublec/libnds) code. You don't have to eat your DS anymore to record sound.
I copied the mic functions from libnds and modified them. Also, I removed unnecessary (IMO) stuff from the arm7 vblank handler, like rtc and temperature reading to get rid of the distorsion. A better way is of course to only disable this stuff when you are recording.
Feel free to do whatever you like with the source. I will release a slightly updated sampling keyboard soon.
Bye,
Tob
#71383 - knight0fdragon - Sun Feb 12, 2006 8:18 am
ok I must be missing something here, because when i ran a test, -1 turned out to be 0xFF, not 0x81 like what I am assuming people are doing
to verify my test
int ii = -1;
int temp = 128;
for (int i = 0; i < 8; i++)
{
if( ii & temp)
iprintf("1");
else
iprintf("0");
temp>>=1;
}
which will result in 1111 1111 instead of 1000 0001 which leaves me to beleive it is twos compliment. unless someone can show me documentation on why ^80 converts a sign to unsign
my lesson on twos compliment
original binary = 1
0000 0001
^0xFF
1111 1110
+ 1
1111 1111
new binary = -1
so formula should be ^0xFF + 1
_________________
http://www.myspace.com/knight0fdragonds
MK DS FC: Dragon 330772 075464
AC WW FC: Anthony SamsClub 1933-3433-9458
MPFH: Dragon 0215 4231 1206
#71399 - tepples - Sun Feb 12, 2006 3:56 pm
Unsigned byte values go from 0x00 through 0xFF. Two's complement signed byte values go from 0x80 through 0x7F.
It'd be easier to give an example if phpBB had a table tag.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#71404 - knight0fdragon - Sun Feb 12, 2006 4:52 pm
that still doesnt give me an answer though, by switching the last bit on an unsigned byte would give me 2 zeroes, and that I cannot find. i get -128-127,where 0 = 0000 like you said. If data is written in twos compfrom the get-go, going from 01111111(127 Unsigned) to 11111111(255 unsigned) results in -1 signed, and last i checked 127 and -1 are not inverses lol
_________________
http://www.myspace.com/knight0fdragonds
MK DS FC: Dragon 330772 075464
AC WW FC: Anthony SamsClub 1933-3433-9458
MPFH: Dragon 0215 4231 1206
#71457 - chishm - Mon Feb 13, 2006 12:33 am
To understand how it works, do the obvious way of going from signed to unsigned -- add 128 to it.
So -2 + 128 = 126.
In 8-bit hex: 0xfe + 0x80 = 0x17e including carry, or 0x7e after rounding
Now do it using an xor with 0x80:
0xfe ^ 0x80 = 0x7e
Notice how the two operation give the same result.
_________________
http://chishm.drunkencoders.com
http://dldi.drunkencoders.com
#71475 - knight0fdragon - Mon Feb 13, 2006 2:28 am
chishm wrote: |
To understand how it works, do the obvious way of going from signed to unsigned -- add 128 to it.
So -2 + 128 = 126.
In 8-bit hex: 0xfe + 0x80 = 0x17e including carry, or 0x7e after rounding
Now do it using an xor with 0x80:
0xfe ^ 0x80 = 0x7e
Notice how the two operation give the same result. |
um are you trying to prove my point or not?? because from what I remember -2 and 126 are not inverses, so its not a proper sign to unsign conversion
_________________
http://www.myspace.com/knight0fdragonds
MK DS FC: Dragon 330772 075464
AC WW FC: Anthony SamsClub 1933-3433-9458
MPFH: Dragon 0215 4231 1206
#71481 - chishm - Mon Feb 13, 2006 4:00 am
I'm am proving that it works. To go from signed to unsigned 8-bit values, you want to add 128, since signed values range from -128 to 127, and you want them to range from 0 to 255.
So converting -2 to an unsigned value, preserving order of values, you add 128 to it. This gives a result of 126.
Again, in hex: 0xfe (-2) + 0x80 (128) = 0x7e (126)
And using an xor with 0x80: 0xfe (-2) ^ 0x80 = 0x7e (126)
We are not finding the absolute value. We are shifting every value up by 128. Getting the absolute value will not preserve the order of the values. That is, we want -2 to be less than 1, even after conversion to unsigned. Adding 128 to both values gives 126 < 129, which is true. Finding the absolute value gives 2 < 1, which is clearly false.
_________________
http://chishm.drunkencoders.com
http://dldi.drunkencoders.com
#71483 - tepples - Mon Feb 13, 2006 4:10 am
Unsigned linear PCM audio data is defined on a linear scale from 0 to some positive voltage rail. Signed audio data is defined on a linear scale from a rail of negative voltage to a rail of positive voltage. To convert from unsigned to signed, subtract the average DC value, which should usually be half the unsigned code's positive rail.
For 8-bit data, the proper identities are - unsignedVal = signedVal + 0x80
- signedVal = unsignedVal - 0x80
but because it wraps around at 256, both the + 128 and the - 128 operations are equivalent to ^ 0x80.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#71518 - knight0fdragon - Mon Feb 13, 2006 7:47 am
ok now i think what tepples is saying is kind of making sense to me.
What i get from the mic is unsigned, where the negative highest wave length starts at 0, neutral would be at 127/128 and the positive highest would be at 255, now what i want to do with the bit is shift it so that i get a value of -127 to 127 or whatever
_________________
http://www.myspace.com/knight0fdragonds
MK DS FC: Dragon 330772 075464
AC WW FC: Anthony SamsClub 1933-3433-9458
MPFH: Dragon 0215 4231 1206
#71607 - knight0fdragon - Mon Feb 13, 2006 7:07 pm
0xtob any chance to get an example of the code you provided?? When I just popped ur code in, it recorded the sound but my voice was slower
_________________
http://www.myspace.com/knight0fdragonds
MK DS FC: Dragon 330772 075464
AC WW FC: Anthony SamsClub 1933-3433-9458
MPFH: Dragon 0215 4231 1206