teaching machines

Beat Mixer – Final – wirthaw

December 20, 2011 by . Filed under cs491 mobile, fall 2011, postmortems.

For my final project my original idea was to create a beat box app that would allow you to record and overall different beats to make a beat with your own voice. Long story short that didn’t happen. After an epic virus that deleted my computers boot files(good defense panda cloud antivirus!) and some difficulties with sound pool (prior to all my files being lost), I decided to take a different approach on this app. My new approach was to pre-make some beats and allow the users to pick and choose which ones they wanted to play. In addition users can also record their own beat and play it along with the pre-recorded ones.

 

The app starts off with a title screen that users just need to tap to start the actual app(not shown). The first picture is the first screen. On the this activity when users tap one of the pictures one of the beat will begin playing. In order to keep the rhythm consistent when a user selects a new beat after the first beat it will not begin playing until the first beat that was selected finishes and calls on completion. Upon completion a wait list possibly containing new beats that are sitting and waiting to start is checked and then the beats waiting are started. For all the beats i decided to use seekTo(0) and .start() in the onCompletionListener instead of simply using player.setLooping(true) so that i could control beat delays (for the recorded voice) and so i could do checks in between each loop. When the beats are selected I change the view background color to yellow with v.setBackgroundColor. When they are clicked again, they stop playing and v.setBackgroundColor(Color.TRANSPARENT). In order to avoidance latency issues i never release the players but simply pause them and call player.seekTo(0);. I’m guessing if i actually released them it wouldn’t be a big issue to load them each time they are called because they are not stored on the sdcard and they are very small files, but why risk it.

The second part of the app is the users ability to record. When users click on the recording mic it sends them to a new activity(pic 3) that allows for a simply start beat delay change, the ability to record and test play. The duration shows the beatDuration-beatDelay(originally zero because no song recorded and no beat delay entered). In order to change that users must record! By clicking record the app makes these calls

Intent intent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION);
startActivityForResult(intent, ACTIVITY_RECORD_SOUND);

That starts an activity to the devices built in voice recorder(doesn’t work on emulator unless you fake an sd card). ACTIVITY_RECORD_SOUND is just a int for the activity result. After the recording finishes the activity passes back a Uri string which is easy to parse and make a media player based on that. A few quick notes about this. First, the built in voice recorder adds a few hundred milliseconds of dead noise that is really only noticable when looping so its crucial to edit the starting delay. Second, is I could not figure out how to get a sound pool to work with the Uri. I tried many different ways but nothing seemed to work. It would have been ideal to use a sound pool because i could have messed with the frequency which would have been sweet! Anyway, from the created media player you can call player.getDuration() to get the media duration. After it is recorded you can test play it and change the beat delay.

To go back to the first activity users must use the back button and now the play button(recorded voice) will work in the mainActivity.

On a final note (for the final project ha) I custom made all the beats using tiny sound clips from free-loops.com! Oh and don’t use this with the emulator, it will not work well.