[LiveWallpaper DEV] DeadMau5 Audio Visualizer [v1.4]

Search This thread

Metastable

Senior Member
May 11, 2010
419
105
Chicago
I've been working on a new Live Wallpaper with a DeadMau5 theme to it. Decided to make a build thread because I don't see many around this forum and thought it would be interesting to do.

The goal is to recreate DeadMau5's current concert setup:
tqM2t.jpg

8n9ay.jpg


It is being coded in pure Java using OpenGL ES 1.0. As I am only starting to use OpenGL ES and I think 1.0 is slightly more beginner friendly due to not needing to create a custom pipeline, I choose 1.0 though may move to 2.0 later.

I initially started by creating an LED class which is basically a primitive cube:
Code:
public class Led{
	 public Led(float width, float height, float depth) {
	        width /= 2;
	        height /= 2;
	        depth /= 2;

	        float tempVertices[] = { -width, -height, -depth, // 0
	                        	  width, -height, -depth, // 1
	                        	  width,  height, -depth, // 2
	                        	 -width,  height, -depth, // 3
	                        	 -width, -height,  depth, // 4
	                        	  width, -height,  depth, // 5
	                        	  width,  height,  depth, // 6
	                        	 -width,  height,  depth, // 7
	        };

	        short tempIndices[] = { 0, 4, 5, 0, 5, 1, 
	        					1, 5, 6, 1, 6, 2, 
	        					2, 6, 7, 2, 7, 3, 
	        					3, 7, 4, 3, 4, 0, 
	        					4, 7, 6, 4, 6, 5, 
	        					3, 0, 1, 3, 1, 2,};
	        
	        vertices = tempVertices;
	        indices = tempIndices;
	    }
	
	public void setColor(float red, float green, float blue, float alpha) {
		super.setColor(red, green, blue, alpha);
	}

        private float red, green, blue, alpha = 0f;
        private float[] vertices;
        private short[] indices;
}


I then created a Panel class which creates a flat array of Leds 10x10 for a total of 100 leds per panel. Then finally with a Cube class that creates an array of Panels, translated and rotated to create the final Cube image, here:
Punch.png

pStFn.png

krK77.png


Which I think is decent reproduction of the real thing:
wydey.jpg



I then set off on being able to display images onto my glorious cube of light. OpenGL allows you to change the color of the elements that you are drawing, in this case cubes.

I contemplated the best approach on doing this, ultimately settling on drawing onto a bitmap and then mapping out my Leds to individual pixels of said bitmap. I draw what I want onto a bitmap of dimensions 119x145. It only needs to be this small because the amount of data that I can display on the cube is limited to how many Leds I use. At the moment there is a total of 7500 Leds in my cube. If I ever decide to increase the amount of Leds per panel I would then need to increase the size of my bitmap.

The process of mapping the actual Leds to pixels took the longest time of the entire project so far. Having to manually map 7500 pixels is not very fun. Originally creating a byte[] containing all the coordinates I was able to start the mapping process, one... pixel... at a time. I eventually ran into a wall because apparently you can only have so many bytes in your constructor, damn. The next logical step was to move over all the mappings onto an external file and then read from it when needed.

So I created this:
Code:
public class PixelMapper {
	public static void main(String[] args) throws IOException {
		InputStream stream = new FileInputStream("C:/Users/Jano/Documents/DeadMau5 Audio Visualizer/cube_mapping.txt");
	    Scanner s = new Scanner(stream);
	    List<Byte> bytes = new ArrayList<Byte>();
	    while (s.hasNextByte()) {
	        bytes.add(s.nextByte());
	    }
	    byte[] byteArray = new byte[bytes.size()];
	    for(int i = 0; i < bytes.size(); i++)
	    	byteArray[i] = bytes.get(i);
	    FileOutputStream out = new FileOutputStream(new File("C:/Users/Jano/Documents/DeadMau5 Audio Visualizer/cube_mapping"));
	    out.write(byteArray);
	    
	    System.out.println("Completed!");
	}
}

This little piece of code does two things, reads a text file containing all of my coordinates and writes them onto a binary file. I had first read straight from the text file in my wallpaper but the process would take way too long, I'm talking 3 minutes plus long. It seems my phone was simply too slow for the task and much prefers reading from a binary file, which completes in under 5 secs.

After all of the grueling mapping that had to be done, I was rewarded with this:
acuiw.png


And here it is with a gray background to better see what's going on:
f5IK2.png


It is not a static image displayed on the cube but a dynamic image that goes to the music being played. I used the Laser Visual that I had developed for my first Live Wallpaper, Epic Audio Visualizer, to provided the lovely images.

Initially the cube would refresh very slowly, perhaps 5-10 fps, as I each Led would draw itself, making OpenGL ES crawl. So I set out to find a way to speed up the process and thus learned about Batchers.

A Batcher takes all of your vertices, in this case 8 per led, and draws them in one OpenGL call. It increased performance greatly but I lost the ability to change the color of each Led, thus no more lovely pictures. That was until I figured I could use OpenGL once again to solve this issue.

OpenGL ES allows you to assign a color to each vertex and create smooth color transitions between vertices. I don't want smooth transitions between Leds, just solid colors for each one. To remedy the problem and created a float[] and when ever I grab a color from the bitmap I copy it to the array 8 times, once per vertex. I'm not entirely sure this is the most efficient process but I couldn't find another solution that said otherwise.

Surprisingly, it worked rather well and I now get ~30 fps, which is what I currently have it hard maxed at.

With that now complete and my cube running smoothly, dancing away to Pandora, I set out to reproduce the VersaTubes(that's what I discovered they are called) in the background. They look like narrow strips of Leds together, so that's what I called my next class, Strip ;].

Similar to my Panel class, it creates an array of Leds width x height. In my case I create 2 different strips, 2x40 and 2x40. From pictures that I have looked it, it looks like the smaller strips are exactly half the size of the larger ones. Getting all of the positioning and adjustments right, I now have a decent reproduction of the VersaTubes.
8Ii0d.png

ITYeN.png

edx9E.png

lEJCK.png



My next step is going to be mapping out the strips (exciting! /sarcasm), which should not be too bad. I have already figured out that I will be needing a bitmap of dimensions 54x40, which is great because the smaller the bitmap the less time it times to draw onto it and map the colors.

And that is where I am currently in the project. Congrats on reading that giant wall of text and pictures, I hope you found some enjoyment/motivation/ideas/what ever. As you have probably seen, the cube is not a solid object in itself, but I don't plan on allowing it to rotate that far, if at all, so it really isn't visible when it's actually running.

Look for my next update and I will gladly answer any questions. Feel free to comment and give suggestions. Thanks for reading.
 
Last edited:

drknezz

Senior Member
Aug 11, 2010
223
23
Melbourne
Man this looks slick as! When do you think you'll have a fully operational version so I can run this beast on my Galaxy S? =D
 

Metastable

Senior Member
May 11, 2010
419
105
Chicago
Thanks! I'd say another week at least. After the VersaTubes are done I will be adding the DeadMau5 LED head and then finishing touches, such as spotlights to create a true concert feel.
 

blazelazydays

Senior Member
Aug 9, 2011
150
9
this is probably the best live wallpaper concept I've seen. can't wait man!

Sent from my Nexus S 4G using XDA App
 

killersnowman

Senior Member
Mar 5, 2011
327
54
SLO
i just started programming (4 months ago) again after 4 years and all the logic is still there but im a bit rusty on some of the syntax. what does the operator '/=' do?

Code:
                width /= 2;
	        height /= 2;
	        depth /= 2;

i cant remember and any search for '/=' returns nothing usefull. i gotta dig up my Kernighan & Ritchie 'The C Programming Language' book. its got most of the syntac for modern languages in it. (and yes i know you are using java, but java is C like in syntax..)

thanks

/=/=/=/=/=/=/=/=/=\=\=\=\=\=\=\=\=\

nvm, druggggeedd it up from the dregs of my mem

width = width / 2

correct?
 
Last edited:

Metastable

Senior Member
May 11, 2010
419
105
Chicago
i just started programming (4 months ago) again after 4 years and all the logic is still there but im a bit rusty on some of the syntax. what does the operator '/=' do?

Code:
                width /= 2;
	        height /= 2;
	        depth /= 2;

i cant remember and any search for '/=' returns nothing usefull. i gotta dig up my Kernighan & Ritchie 'The C Programming Language' book. its got most of the syntac for modern languages in it. (and yes i know you are using java, but java is C like in syntax..)

thanks

/=/=/=/=/=/=/=/=/=\=\=\=\=\=\=\=\=\

nvm, druggggeedd it up from the dregs of my mem

width = width / 2

correct?

Yes that is correct and the same syntax can be used for just about any operation, +=, -=, *=, etc.

Man can't wait for this!

Me either, lol.
 
Well this is funny. I too was working on a deadmau5 LWP and was just going to post my WIP and saw this glorious thread which makes mine look like a kindergarden project. I was inspired to make one after seeing mau5 @ lollapalooza this past weekend... [what a show] anywho I cant wait to have this on my captivate... Here is a screenie of mine so far...

Sent from my GT-I9000 using XDA Premium App
 

Attachments

  • uploadfromtaptalk1313121063049.jpg
    uploadfromtaptalk1313121063049.jpg
    20.9 KB · Views: 775
  • Like
Reactions: imfloflo

Metastable

Senior Member
May 11, 2010
419
105
Chicago
Well this is funny. I too was working on a deadmau5 LWP and was just going to post my WIP and saw this glorious thread which makes mine look like a kindergarden project. I was inspired to make one after seeing mau5 @ lollapalooza this past weekend... [what a show] anywho I cant wait to have this on my captivate... Here is a screenie of mine so far...

Sent from my GT-I9000 using XDA Premium App

That's a great idea, regardless! I hope you still go about posting your WIP, build threads are lacking in this sub-forum.

Looks awesome, I can't wait to give it a go when it's done! :)

+1. Always wanted a good version of this on CM7. The sense onset are not even close to this :D


Sent fron my MIUIUIUIUIaka Meringue powered DHD

Soon I promise! Will be updating soon as I finish mapping the VersaTubes.
 

Metastable

Senior Member
May 11, 2010
419
105
Chicago
Progress Update!

Just finished mapping out the VersaTube reproduction and it looks pretty sweet! Before I show the goods, I'll just do a brief explanation of the work that went into it.

If you read the OP then you already know that the VersaTubes are very similar to the cube in that they are arrays of LEDs or primitive cubes. Unlike the cube I split the VersaTubes into two object. Tubes1 contains the larger strips with dimensions 2x40, Tubes2 are half the height, 2x20. Two separate mappings were done, one for each object. Both Tube objects grab the pixels from the same bitmap however so they are in complete sync with each other. Though that could very well change if I want to do some fancy effects by changing the two of them.

Here's some code of how I grab the binary mappings that I create with the previous bit of code that I posted:
Code:
private void populateTubesMap() {
		Log.d(TAG, "Populating tubes map...");
		
		tubes1PixelMap = new byte[tubes1.ledArray.length * 2];
		tubes2PixelMap = new byte[tubes2.ledArray.length * 2];
		
		readMappings(R.raw.tubes1_mapping, tubes1PixelMap);
		readMappings(R.raw.tubes2_mapping, tubes2PixelMap);
	}

private void readMappings(int resourceId, byte[] array) {
		try {
			DataInputStream stream = new DataInputStream(engine.res.openRawResource(resourceId));
			stream.read(array);
		} catch (IOException e) {
			Log.d(TAG, "populating failed!");
			e.printStackTrace();
		} catch (Resources.NotFoundException e) {
			Log.d(TAG, "populating failed!");
			e.printStackTrace();
		}
	}

I multiply the length of my ledArray for each tube by 2 because I require an X and Y coordinate to be able to map pixels. Then you can see the method that does the binary reading. It's pretty simple and gets the job done very quickly. I don't do any error handling really because it shouldn't fail, and if it does I don't see anyway of recovering.

With all that done my VersaTubes come to life! Here's the goods:

kZZKo.png


3puhG.png


And a side shot to get a little closer to the tubes:
tvusY.png


There ya go! Both the cube and tubes react to music and I currently have it updating at 40fps. Mind you the actual rendering may be going at a faster rate, I haven't actually measured it, I will do that soon to give you guys some numbers of how fast it renders. It looks sweet, I may post a video up soon if I can snag my girlfriends Captivate for long enough to record and upload.

Let me know what you think! I haven't decided if I should the long LED drape looking things in the background that you can see here:

SjiPp.jpg


In the meantime I decide about that, I'll be working on reproducing the DeadMau5 LED head:
B4orL.jpg


I'll be using a smaller led size to create a more detailed feel.

Wish me luck!
 

Metastable

Senior Member
May 11, 2010
419
105
Chicago
Was watching some videos of his last show at Lollapalooza (I knew I should have jumped the fence >>) and it looks like he switched up his setup again... I'm going to continue with the previous setup that has the VersaTubes. Perhaps later down the road I will offer an option to switch between concert setups. Perhaps.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 30
    I've been working on a new Live Wallpaper with a DeadMau5 theme to it. Decided to make a build thread because I don't see many around this forum and thought it would be interesting to do.

    The goal is to recreate DeadMau5's current concert setup:
    tqM2t.jpg

    8n9ay.jpg


    It is being coded in pure Java using OpenGL ES 1.0. As I am only starting to use OpenGL ES and I think 1.0 is slightly more beginner friendly due to not needing to create a custom pipeline, I choose 1.0 though may move to 2.0 later.

    I initially started by creating an LED class which is basically a primitive cube:
    Code:
    public class Led{
    	 public Led(float width, float height, float depth) {
    	        width /= 2;
    	        height /= 2;
    	        depth /= 2;
    
    	        float tempVertices[] = { -width, -height, -depth, // 0
    	                        	  width, -height, -depth, // 1
    	                        	  width,  height, -depth, // 2
    	                        	 -width,  height, -depth, // 3
    	                        	 -width, -height,  depth, // 4
    	                        	  width, -height,  depth, // 5
    	                        	  width,  height,  depth, // 6
    	                        	 -width,  height,  depth, // 7
    	        };
    
    	        short tempIndices[] = { 0, 4, 5, 0, 5, 1, 
    	        					1, 5, 6, 1, 6, 2, 
    	        					2, 6, 7, 2, 7, 3, 
    	        					3, 7, 4, 3, 4, 0, 
    	        					4, 7, 6, 4, 6, 5, 
    	        					3, 0, 1, 3, 1, 2,};
    	        
    	        vertices = tempVertices;
    	        indices = tempIndices;
    	    }
    	
    	public void setColor(float red, float green, float blue, float alpha) {
    		super.setColor(red, green, blue, alpha);
    	}
    
            private float red, green, blue, alpha = 0f;
            private float[] vertices;
            private short[] indices;
    }


    I then created a Panel class which creates a flat array of Leds 10x10 for a total of 100 leds per panel. Then finally with a Cube class that creates an array of Panels, translated and rotated to create the final Cube image, here:
    Punch.png

    pStFn.png

    krK77.png


    Which I think is decent reproduction of the real thing:
    wydey.jpg



    I then set off on being able to display images onto my glorious cube of light. OpenGL allows you to change the color of the elements that you are drawing, in this case cubes.

    I contemplated the best approach on doing this, ultimately settling on drawing onto a bitmap and then mapping out my Leds to individual pixels of said bitmap. I draw what I want onto a bitmap of dimensions 119x145. It only needs to be this small because the amount of data that I can display on the cube is limited to how many Leds I use. At the moment there is a total of 7500 Leds in my cube. If I ever decide to increase the amount of Leds per panel I would then need to increase the size of my bitmap.

    The process of mapping the actual Leds to pixels took the longest time of the entire project so far. Having to manually map 7500 pixels is not very fun. Originally creating a byte[] containing all the coordinates I was able to start the mapping process, one... pixel... at a time. I eventually ran into a wall because apparently you can only have so many bytes in your constructor, damn. The next logical step was to move over all the mappings onto an external file and then read from it when needed.

    So I created this:
    Code:
    public class PixelMapper {
    	public static void main(String[] args) throws IOException {
    		InputStream stream = new FileInputStream("C:/Users/Jano/Documents/DeadMau5 Audio Visualizer/cube_mapping.txt");
    	    Scanner s = new Scanner(stream);
    	    List<Byte> bytes = new ArrayList<Byte>();
    	    while (s.hasNextByte()) {
    	        bytes.add(s.nextByte());
    	    }
    	    byte[] byteArray = new byte[bytes.size()];
    	    for(int i = 0; i < bytes.size(); i++)
    	    	byteArray[i] = bytes.get(i);
    	    FileOutputStream out = new FileOutputStream(new File("C:/Users/Jano/Documents/DeadMau5 Audio Visualizer/cube_mapping"));
    	    out.write(byteArray);
    	    
    	    System.out.println("Completed!");
    	}
    }

    This little piece of code does two things, reads a text file containing all of my coordinates and writes them onto a binary file. I had first read straight from the text file in my wallpaper but the process would take way too long, I'm talking 3 minutes plus long. It seems my phone was simply too slow for the task and much prefers reading from a binary file, which completes in under 5 secs.

    After all of the grueling mapping that had to be done, I was rewarded with this:
    acuiw.png


    And here it is with a gray background to better see what's going on:
    f5IK2.png


    It is not a static image displayed on the cube but a dynamic image that goes to the music being played. I used the Laser Visual that I had developed for my first Live Wallpaper, Epic Audio Visualizer, to provided the lovely images.

    Initially the cube would refresh very slowly, perhaps 5-10 fps, as I each Led would draw itself, making OpenGL ES crawl. So I set out to find a way to speed up the process and thus learned about Batchers.

    A Batcher takes all of your vertices, in this case 8 per led, and draws them in one OpenGL call. It increased performance greatly but I lost the ability to change the color of each Led, thus no more lovely pictures. That was until I figured I could use OpenGL once again to solve this issue.

    OpenGL ES allows you to assign a color to each vertex and create smooth color transitions between vertices. I don't want smooth transitions between Leds, just solid colors for each one. To remedy the problem and created a float[] and when ever I grab a color from the bitmap I copy it to the array 8 times, once per vertex. I'm not entirely sure this is the most efficient process but I couldn't find another solution that said otherwise.

    Surprisingly, it worked rather well and I now get ~30 fps, which is what I currently have it hard maxed at.

    With that now complete and my cube running smoothly, dancing away to Pandora, I set out to reproduce the VersaTubes(that's what I discovered they are called) in the background. They look like narrow strips of Leds together, so that's what I called my next class, Strip ;].

    Similar to my Panel class, it creates an array of Leds width x height. In my case I create 2 different strips, 2x40 and 2x40. From pictures that I have looked it, it looks like the smaller strips are exactly half the size of the larger ones. Getting all of the positioning and adjustments right, I now have a decent reproduction of the VersaTubes.
    8Ii0d.png

    ITYeN.png

    edx9E.png

    lEJCK.png



    My next step is going to be mapping out the strips (exciting! /sarcasm), which should not be too bad. I have already figured out that I will be needing a bitmap of dimensions 54x40, which is great because the smaller the bitmap the less time it times to draw onto it and map the colors.

    And that is where I am currently in the project. Congrats on reading that giant wall of text and pictures, I hope you found some enjoyment/motivation/ideas/what ever. As you have probably seen, the cube is not a solid object in itself, but I don't plan on allowing it to rotate that far, if at all, so it really isn't visible when it's actually running.

    Look for my next update and I will gladly answer any questions. Feel free to comment and give suggestions. Thanks for reading.
    4
    Updated APK!

    Alright people, here's the latest version that I'm running on my phone at the moment. It's lighter and faster while still having more to show off. I just got it to a state that I am happy with to release so the backing and the longer strips only have 1 visual mode at the moment. Test it out and let me know what you think, especially with the Mau5Head.

    P.S. Don't mind the version number, I haven't decided if the official release is different enough to go 2.0 or not.
    4
    Beta v0.9.9

    Okay, guys, your patience has payed off! I finally have the wallpaper running on Samsung phones and most likely the other phones that were only showing one frame. It was a very simple issue that I overlooked and for some reason wasn't an issue with my and others phones when it should have been.

    Test it out and let me know if it works for you! This will be the last beta before I throw it up on the market unless there are still issues that need to be cleared up. v1.0 will have a proper icon but besides that this will be identical to v0.9.9.

    Enjoy!
    2
    Something neat that I've only seen at the venue we were at, the Palladium, the 2 cubes on the floor rise during certain songs. Work of magic.

    Any sufficiently advanced technology is indistinguishable from magic. - Arthur C. Clarke

    Luvin' it! How exactly can I download it from BitBucket. It seems I can't get a download from the given link?

    Browse through the source files, it should be under the "bin" folder.

    Here's a preview of what's coming in the next version:
    jnF8T.png


    All done in Blender.
    2
    Beta v1.4

    Hey, guys, it has been awhile since I've posted a new beta version. I've been rather busy with school and other projects. Here's a small portion of what I want to do with the next release. The Mau5Head moves once again! There's also a new visual in the backing that I added.

    In the next release I hope to add a new option that will keep the visuals in a sort of static state. The visuals will continue to cycle through themselves but they will keep a predetermined state so it will look better when there is no music playing.

    In the mean time here's the APK for the previous additions.

    EDIT: Uploaded a newer version that includes the "static" option that I was talking about above. It generates an array of numbers that are used to visualize when there is no music to use. It's not 100% static because some visuals are generated randomly meaning they choose random numbers within this array by design so they aren't exactly static. Let me know what you guys think!