Archive for June, 2015

MediaPlayer onCompletionListener

Sunday, June 21st, 2015

Another way to create an endless loop, I’m thinking, is by using the onCompletionListener function which seems very convenient.  I would imagine it’s fantastic for creating a playlist of song by tying it up with an array of songs or a set of pointers to songs in a database.  But since I’m looking to call the same fragment repeatedly, my code ends up being somewhat recursive.

The Background constructor looks like this:

Background(Context con) {
context = con;
mp1 = MediaPlayer.create(context, R.raw.neroli2);
mp1.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mediaPlayer) {
mediaPlayer.seekTo(0);
mediaPlayer.start();
}
});

Now the call from the UI is even simpler:

public void play() {
mp1.start();

As unbelievably clean as this code is, it still creates a .31 second gap, which wouldn’t be terrible if this was between tracks, but it’s not seamless yet.

I would be remiss if I didn’t give a shout-out to the folks who created IntelliJ platform.  The prototyping for the setOnCompletionListener was awe inspiring.  Type in “new MediaPlayer.OnCompletionListener” and the rest of the framework is automatically inserted into your code.  I’m still in disbelief it’s that smart.  🙂

 

Android MediaPlayer looping issues.

Friday, June 19th, 2015

Looping isn’t seamless

I’m finding that some parts of the Android MediaPlayer are perhaps harder to work on.  I’ve been putting some code together to endlessly loop a short 30 second clip for the background of the Bloom project.

The code looks like this:

public class Background {
MediaPlayer mp1;

Background (Context con) {
mp1 = MediaPlayer.create(context, R.raw.soundsample1);
}

Play() {
mp1.setLooping(true);
mp1.start();
}

The simplicity is breathtaking.  Create an instance of a MediaPlayer object in the constructor then when the user presses “play”, start the sound.  Nice.

The only problem is that there is a discernible gap between the end of the plays in the loop.  It’s about 8 hundredths of a second which isn’t much, but it annoys me and that’s all it takes.

Next up – my attempt to fix this through threading.

More later…

Building an Android Bloom

Friday, June 19th, 2015

Bloom is a generative music program written for the iPod, iPad and iTouch products.  I think it’s one of the coolest programs available, mostly because I seriously love Eno’s sense of ambient and the options available (Shuffle mood, Evolve when idle, etc).  When I press the screen it plays a note and draws a colored circle which expands while the note plays and fades.  This is similar to the tape-delay system introduced with Discreet Music and used in early versions of Frippertronics.

0619150848

But this app has been available for the Apple for years so it doesn’t appear that the folks who created it have ambitions on the Android platform and other generative music programs just don’t create the environment like Bloom.  So, I’ve decided to try to write it for Android.

Having set this as a challenge to myself, I realize how many years it’s been since I’ve written code but Android development (and any development frankly) has come so far since the days of C++ coding with command line compilers, non-integrated source control and special math libraries, even an old man can put something together.  Maybe.

 

No news is no news

Friday, June 12th, 2015

There was a time and it wasn’t so long ago when there was a common courtesy in the hiring process.  When you applied for a position through the medium of e-mail, you received an automatic confirmation return which gave a mild satisfaction of knowing it was received correctly.

That doesn’t happen anymore.

What I’m referring to is a newer and, in my opinion, a ruder form of ignoring a candidate – the callback.

I’m willing to admit that I’m probably not the best candidate for every position as math teacher, tech support or even “human OCR drone.”  But when I’ve done my best to dress professionally, carry copies of my resume, shake hands firmly, answer your questions honestly, take your building tour and meet some of my potential co-workers, the very least you could do is sit down for a minute or two.  Send me an email!

</rant>