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 Misc > DS Sampling Keyboard

#56404 - 0xtob - Sat Oct 08, 2005 4:18 pm

Hi everyone!

This is my first program for the DS: A Sampling Keyboard using the DS's microphone. Check it out, I think it's quite funny. Please leave your comments and suggestions here or drop me a line.

Tob

#56411 - TheChuckster - Sat Oct 08, 2005 4:41 pm

Is this virused?

#56412 - Dannon - Sat Oct 08, 2005 4:45 pm

Is everybody else slightly dubious about running programs from newly registered and not yet trusted members?! I'm sure it's fine, but there is a lingering thought that maybe just maybe this will mess with the firmware

#56414 - JaJa - Sat Oct 08, 2005 4:48 pm

This virus thing has really shaken the whole community.
I would try it, and it's not that i don't trust you but... you know how it is.

#56420 - TheChuckster - Sat Oct 08, 2005 5:20 pm

Okay, I tried it out and it's really cool. I tried banging on glass, guitars, short speech, making alien noises, and ukuleles for samples. It's fun playing Fuer Elise on this thing: E Eb E Eb E B D C A

Glissandos are fun on this thing.


Last edited by TheChuckster on Sat Oct 08, 2005 5:43 pm; edited 3 times in total

#56422 - 0xtob - Sat Oct 08, 2005 5:29 pm

Man, I really could slap Dark Fader for releasing his "virus" thingy. I know this was my first post, but everyone has a first time and I'm just not the talker kind of guy. I find it really sad that you are suspecting me of this, but on the other hand I understand this fear. Perhaps some of you know me from IRC, we once had a lively discussion about this virus-thing and I am strongly against it, even against using it on pirates and I sort of feared that a thing like this would happen.

I don't know how I can assure you that this is for real other than begging you to trust me and to ask yourself why the hell I would make a thing like that up. Would I spend hours to design a fake screenshot and homepage? So please, if anyone tried this, please post a message confirming that this is virus-free so that no one is afraid of downloading this anymore. It's really a funny program - not only for me.

Thanks,
Tob

Edit: OK, I wrote this before Chuckster's post. I hope you are not afraid anymore :-)

#56423 - TheChuckster - Sat Oct 08, 2005 5:31 pm

Suggestions:

Make the keyboard fit 100% width of the DS screen instead of having margins on the right and left edges. More/bigger keys.

Fix touching between two keys causing a nasty sound since it can't decide which key to play.

Multi sample memory and selection menu on the top screen. Record up to say 5 samples and use arrow keys to toggle between them.

Fun settings/effects to mess with that affect the sound. Ex: Pitch slider using touch screen, oscillation/envelope/cut off/pitch knobs like on synths,
reverb/chorus effects, anything else you can think of. I would be the last person that would know anything about actually implementing any of these though.

Demo button! (Plays a catchy tune a la Casio keyboards)

Possibly a TB303 emulator or drum machine?

Built-in high quality samples of real instruments.

#56424 - TheChuckster - Sat Oct 08, 2005 5:33 pm

Make the keys bigger then have two arrows on each side below the keyboard that causes the keyboard to scroll to allow for more range. Might work better with builtin samples than trying to overly distort the already low-quality mic recorded samples though.

#56425 - 0xtob - Sat Oct 08, 2005 5:45 pm

Chuckster: Thanks for all the cool suggestions! I think I can do some of the tings you mentioned.

Making the keyboard broader would be a bit hard since I display it using tiles which fixes me to a key width divisible by eight pixels. I was thinking about displaying two keyboards above each other, so you can play four octaves. Then, I would perhaps use the first octave to pich the sample down.

I was also thinking of including pre-made samples, but I don't know where to get freely distributable ones. I don't know how legitimate it is to just rip them from XMs. Any hints?

I will work on input stability. The jumping between two notes will decrease when I sacrifice the sliding feature, but I kind of like it, so I think I'll see what I can do.

And effects would be cool! I never thought of that. Stuff like echo and lowpass should also be easy to implement.

So thanks again for the great feedback, expect a new release soon!

Tob

#56428 - TheChuckster - Sat Oct 08, 2005 6:10 pm

http://www.modarchive.com/waveworld/

Might have to rename the files you download there to have a .zip extension. I had to and it worked from there.

They have the entire TB909 drum set among other things!

#56433 - tssf - Sat Oct 08, 2005 6:58 pm

I really like this program. It would be really cool if you could add tracks and such in the future. :) Maybe even a primitive "tracker" of some sort.

Oh man that would kick so much ass, a Nintendo DS mod Tracker :D
_________________
Mathew Valente [TSSF]
------
Chrono Resurrection Musician

#56435 - amiga - Sat Oct 08, 2005 7:13 pm

I've tried it and it's really funny and I think it could be really interesting with the improvements.

#56436 - 0xtob - Sat Oct 08, 2005 7:14 pm

tssf: Well who knows ;-)

#56441 - JaJa - Sat Oct 08, 2005 8:06 pm

This is actually one of the best bits of homebrew i've used to date.
Any chance the source will be released for the sound modification?
What code do you use to modify the sound?
Is the sound stored in a buffer?
I ask because i was thinking of doing a similar thing (except it would focus on being a voice changer).

Im sorry i doubted you earlier, but better safe than bricked.

#56482 - joebob180 - Sat Oct 08, 2005 11:26 pm

Wow, I cant wait to try this when I get home. I've wanted to start programming some sequencers, because the ds is perfect for sound creation, but havent had much success. Cant wait till you release the source code.

#56494 - 0xtob - Sun Oct 09, 2005 1:46 am

OK, the source is now available from my site. I hope you can use it.

JaJa: Yes, I store the sound in a buffer. The different notes are just different frequencies at which the sound is played back. You don't even need to modify the sound since you can give the DS your desired playback rate directly. This makes it very easy and efficient.

#56527 - JaJa - Sun Oct 09, 2005 10:32 am

Rofl.
Your idea is very similar to mine, except mine would have like 4buttons that are supposed to be different voices.
Your even using doublec's great tutorial code.
Thanks for the code anyhow. Now i need to sit and read and learn how to do buttons and then im pretty much all set.
Can you use lower freq values? the 16000-ish one wasn't really low enough.

#56529 - 0xtob - Sun Oct 09, 2005 11:17 am

I learned how to implement tile-based buttons with palette switching from headspin's keyboard examples which were a great help.

Sure you can use lower frequencies than 16384 so you can pitch the sample down.

#56535 - agentq - Sun Oct 09, 2005 2:22 pm

This is great stuff. It's great fun, works nicely, and has a very swish interface too!

For some reason the recording sound a little glitchy, and having seen this kind of thing before it sounds as if you're not disabling iterrupts while recording your sound. Since reading the mic is very timing dependant, this may well make it sound cleaner.

Although it could well be just the poor mic in the DS.

Also, perhaps there could be a feature to trim the start and end of the sample, so you can record stuff and trim silence from the beginning.

Great job though!

#56538 - 0xtob - Sun Oct 09, 2005 3:18 pm

agentq:

Hey, thanks very much, especially for your suggestions!

I am very interested in improving the microphone quality. In the beginning I had serious static in the recorded sound but I somehow (really, I don't know what I changed) fixed this.
I am currently not disabling any interrupts when recording, unless libnds does this implicitly, but I don't think so. Which interrupts do you mean specifically? I think everything that stays on the arm9 should be fine, since the arm7 does the recording. On the arm7, I have the timer0 interrupt that is called on every sample and the vblank that is used to handle input. I tried disabling vblank when recording, but the quality of the sound did not change, so I think the vblank is no threat to timing.
Or did I miss something, perhaps other interrupts? Do you know a demo program with better recording quality?

I will definitely try to do silence cropping, that's a cool idea. I just have to think of a way to detect the beginning of the actual sound in the messy output from the mic.

Thanks again!
Tob

#56551 - JaJa - Sun Oct 09, 2005 6:25 pm

Are the frequency values arbitary or are they from a particular source?
There doesn't appear to be a pattern to them.
Can I just pick a lower number or is there actually a patter?

#56562 - 0xtob - Sun Oct 09, 2005 7:29 pm

Jaja:

No, I just picked random numbers and they turned out to be note frequencies :-). No, just kidding. There is in fact a pattern, but it may be hard to spot if you don't know about it.

Say you have a sample of some instrument playing a C-0. If you want to pitch it one octave higher, you have to double the playback frequency. And the logical cosequence is, since an octave has twelve notes (halfnotes included), that you can pitch it by one note by multiplying it by the twelvth root of two (2^(1/12)). So, it you have a note, and you pitch it up by twelve notes, you multiply it by [2^(1/12)]^12=2. Got it?

That's the way note frequency tables are calculated. So, the numbers in the note table are powers of the original note frequency with the fractional part cut off (a little skew doesn't matter).

Tob

#56574 - JaJa - Sun Oct 09, 2005 9:50 pm

Cheers. Once i knew what i was looking for i found a table on google with the lower frequencies.

How comes you code ARM7 code compiles on devkitpro 16a, but doublec's doesn't?

I found the value in the microphone demo, but it doesn't compile, so that's a problem.

I managed to change the freqencies in your app anyway. I prefer the lower spectrum end.

Edit: Do you mind if i use some (*most*) of the code?
I just need to remove the keyboard code and change the backgrounds and it's pretty much done. Will support 4 "voices" and unaltered "voice".

Edit2: What app did you use to export the C array images?
I tried gimp and image-to-gba but they give something different.
Also can i have the image dimensions?

#56589 - tepples - Mon Oct 10, 2005 12:00 am

0xtob wrote:
There is in fact a pattern, but it may be hard to spot if you don't know about it.

The pattern that you go on to describe is called equal temperament, and it's not the only way to tune an instrument. First, there was just intonation, based on integer ratios of frequencies (such as 3/2 for a fifth and 5/4 for a major third), but it produced dissonant wolf intervals between some pairs of scale degrees, especially in keys other than the one that the instrument was tuned for. Later improvements led to meantone temperament and then equal temperament, which were compromises that spread tuning error over all the intervals. But nowadays, computers can switch tunings based on the root of the current chord, as used by Wendy Carlos on Beauty in the Beast (1986). But most consumer synthesizers don't bother with this, and they continue to tune everything in equal temperament, leaving the minor third a bit flat of just and the major third a bit sharp of just.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#56590 - 0xtob - Mon Oct 10, 2005 12:08 am

Jaja:

Well, my code compiles because I rewrote doublec's code using the microphone functions which are now built into libnds. I first tried porting doublec's code but ended up with messy code that did nothing.

The program is GPL, so of course I don't mind if you use the code in your own project as long as you release the source youself.

I wrote my own little image converter that I will eventually release. But it's really not that much/complicated code. About the image dimensions: There are two backgrounds that each fill their respecive screen and the keyboard is 28x5 tiles.

Good luck with your project!
Tob

#56640 - JaJa - Mon Oct 10, 2005 10:23 am

What's the dimension of bgsub?
i know bgmain is 256 x 192, but i can't work out bgsub.
Can anyone suggest an app to create files similar to 0xtob

#56646 - 0xtob - Mon Oct 10, 2005 1:13 pm

tepples: Cool stuff, I didn't know about these different tunings. These Wikipedia-links are an interesing read.

JaJa: What's the problem, bgsub is 256x192, too.

#56647 - JaJa - Mon Oct 10, 2005 1:18 pm

Sorry, i assumed bgsub was your name and stuff. Now i see they're all part of the same image.
Any way thanks for what has formed the basis of my project.

#56936 - 0xtob - Wed Oct 12, 2005 10:35 am

Did anyone here have problems running this program? I heard of a case where it did not work on the M3 Adapter and would of course like to fix this.

#57020 - Sektor - Thu Oct 13, 2005 1:32 am

It works on my M3 Perfect CF. Just need to use the demo loading function of M3 to load it, start button, not A button. Very amusing program, entertained me and quickly annoyed my friends.

#57177 - devmani - Fri Oct 14, 2005 2:52 am

Great app! By the way, is it possible to create IC recorder for DS
that can save some sound data to CF or SD? Isn' this a practical app?

#60842 - pixxel - Tue Nov 15, 2005 7:44 am

if u want some copyright free samples to make a sound lib, i can make my own instrements in the music package i use (jeskola buzz - its not very hard ;) ) or with some of the audio hardware ive got (tho i tend to get better sound out of software these days and its a damned site easier to get it into a usable format) and throw u a bunch, including drums etc (and 303s for the person that asked), all will be copyright free and i wont expect any credit - its just nice to have a toy like this :D

if u do, give me a shout mad_ninja_skillz@hotmail.com (email or msn) and tell me what format u want them in (standard pc wav is best for me, but ive got cooledit so i could give u them raw or iff-8sav if u wanted...

if u were to support loading banks - could they be external (using chisms fat stuff) and also...*beg time* could u save your recorded sounds for when u get that perfect belch ;)

#61134 - Darkflame - Thu Nov 17, 2005 4:46 pm

EXCELENT!

Wow...this thing is fun :)
Great work!

Of course theres loads of little things you could add to this (record to the CF card direct, or play to the CF crd ect). Allthough they would be a lot more work.

But just two simple things would be nice for the next version;
Standby Mode and an Exit function (exit to moonshell)

#61226 - 0xtob - Fri Nov 18, 2005 2:07 am

pixxel:

Hey, cool! Would be nice if you could do that. If they are cool, I would bundle your samples with the next release.

Darkflame:

Thanks ^^
I know there is much that could make it even cooler and I'm currently thinking about what to include without making it too complicated. But standby and exit will definitely come.

Bye,
Tob

#63298 - hamilton - Sun Dec 11, 2005 3:33 pm

something like "microbe" a music app. for Palm, might be worth a look for anybody with ds programming ability. Info about it can be found at the "Bhajis loops" site, just google it. This is exactly the type of app the ds needs! A touch screen portable music app. in the vein of good old rebirth!

#63552 - Darkflame - Wed Dec 14, 2005 4:54 am

A simplified Electroplanton type thing with your own samples would be nice ;)
(thinking of the one on the official demo, with the mario tune)

Shouldnt be two hard, just a series of loops really. No need to have fancy animations.

#71398 - 0xtob - Sun Feb 12, 2006 3:55 pm

Hi!

I just completed version 1.1 of the sampling keyboard!

Fixed problems:
  • Sound quality is vastly improved
  • The microphone is much more sensitive
  • The touchscreen is more accurate
No, I did not forget all your great ideas for new features. I will add them in the next release, just give me time until my other project is released.

Have fun!
Tob

#71407 - Darkflame - Sun Feb 12, 2006 5:46 pm

fantastic, great work!

#71422 - Durandle - Sun Feb 12, 2006 8:27 pm

No go on the M3 CF. Normal start gives black screens (are you missing the PowerOn All line in your code?) and HomeBrew mode loads into the interface and crashes.

#71478 - Sektor - Mon Feb 13, 2006 3:36 am

It works on my M3 CF with firmware E15 and E16. It doesn't display as intended though, for one thing it has a purple background but if I hadn't tried it with WMB, I wouldn't know it was an error.

The .ds.gba version works with A button.
The .nds version works with Start button (demo loading mode).

The sound quality is clearly a lot better than the previous version, great job.


Last edited by Sektor on Mon Feb 13, 2006 5:09 pm; edited 3 times in total

#71500 - m2pt5 - Mon Feb 13, 2006 5:00 am

Very nice. The sound quality seems to be better than many official games.
_________________
Don't sign your posts, it's dumb.

#71521 - HyperHacker - Mon Feb 13, 2006 7:58 am

Ooh, nifty. Quite entertaining. Seems odd that you can't play a lower pitch though.

Nice reference when pressing B BTW. ;-)