Caramelldansen

From ProjectWiki
Jump to: navigation, search

Caramell Dansen Instant Movie Create... for NDS!!!

Contents

What is this?

Main menu...

After making the nyanroll and rickroll video players, wanted to make one more based on the Caramell Dansen series of videos. The result is Caramell Dansen Instant Movie Create, which adds a sorta GUI to the previous players and facilitates recording, storing all the real time effects, scene changes, and other datas. In this way it is possible to create something like 'movies'. :D

I have uploaded a video demonstration to here. (please forgive bad camera quality ;;)

Features:

  • Playback animation loops of various framerates up to 20 frames in duration
  • Special effects such as panning, scaling, rotation, fade to white/black,
  • Mp3 soundtrack
  • cute and colorful appearance (could be better however >_>)
  • Records user inputs and replays in exact timing as performed originally sync'd to the mp3
  • adjustable framerates full stop to 60fps, with single frame advance option
  • GUI using the touchscreen, ooo ahh :p
  • Power Management so closing the lid saves battery..
  • 12 point japanese font renderer with SJIS input rendered in mode5
  • Up to 3 backgrounds are used on engine A (the purpose of this was partly to test background management system)

On cards with slower read times it is likely that the mp3 playback will fail, which would then stop all playback and recording. ;;; On a small, slightly slower, 128MB card a friend has it did work, although mp3 'skipped' a bit when doing rapid fire scene changes. With my Neoflash 8Gb card it plays wonderfully!! :D As i get information about which cards will and will not play may create some type of database. This would be useful for other projects as well to know r/w speed of various cards.

The animation loop data were taking from various .flv animations on the youtube.. Really a shame since its loading them as bitmaps and yet they still end up with numerous artifacts from the .flv format. But i cannot draw well and meh it works. u_u

Where to get it?

Would like to add more dansen loops, make the GUI a bit less clunky, but since its not an extremely serious project this may take some time. (If problems loading and are using a GBA ram cart, try removing it... will fix soon ^^)
here is what's working so far:

  • CaramellDansen v0.3
    • added debug information at startup for troubleshooting
    • reorganized code and moved key detection to vblank interrupt
    • CaramellDansenv0.3 Sources
  • Caramell Dansen v0.2
    • Improved Help menu (press select during rec/pb)
    • Added 2 more animation loops
    • Added low quality mp3 mode
    • Set default centering so that image zooms/rotates to center of image instead of upper corner
    • Changed demo sequence
  • Caramell Dansen v0.1

Note: if anyone happens to make a nice video, send me the cdmovie file or paste a link on the discussion page, would like a better demo :D

Technical Details

Playback go go go... ^^
also note 3 background layers

There are a few ways to do event recording, on thds i simply recorded the keypad inputs every frame for instance, but on this one were numerous technical considerations that required something a bit different. Firstly since it can be played on cards with different loading times and loading of the animation frames may take > one or more vblank intervals, simply recording keypress alone wouldn't stay in sync with the music reliably. Instead here decided to store all events like so:

//Event enumeration table
enum {
	ENVT_RESET,  //Set all position values back to defaults.
	ENVT_ROT,    //rotational angle
	ENVT_ZOOM,   //image scale
	ENVT_SX,     //image scroll
	ENVT_SY,
	ENVT_XC,     //image centering (rotational center)
	ENVT_YC,
	ENVT_FADE,   //fade to black
	ENVT_FADEINC,//fade to white
	ENVT_CHANGE, //select new animation loop
	ENVT_FRATE,  //change framerate
	ENVT_FADV    //advance a single frame
};
 
typedef struct _envt_t {
	int	time;	//in ms how far past start of song for this event
	u32	value;	//
	u16	type;	//event type
} envt_t;

Each event type possible is enumerated, and stored as 'type', a 'value' if necessary, and the 'time' offset in ms from the start of the mp3. The mp3 library can report the offset in ms so this works well. During playback the event's time is compared to the current mp3 time position and it does all events up till the current mp3 time. In this way even if vblanks are missed it will immediately re-sync with the mp3 at the next iteration of the main playback loop... ^_^

while(mp3time>envlist[envcnt].time) {
... //do all the different events
    envcnt++; //move on to the next event....
}

For the video loops had to do a bit differently from previous schemes I'd used whice simply loaded each frame as it was needed for display on the screen. Caramell Dansen stores up to 20 frames in RAM, when the animation sequence changes, it starts loading frames immediately as well as setting the playback speed (fps) and setting the current playback position of animation loop to frame 0. It then attempts to load a frame per vblank until the entire sequence is in ram. The videoUpdate function (called from vblank interrupt), will only play up to the max number of loaded frames sooooo, the result is a best effort animation loop loader.

The animations are stored in the Nitro Filesystem, there is a master animation playlist file called myanimpl.apl which is similar to the mp3's playlist.m3u and contains the path and name of each animation sequence file which have the extention .ani. Inside these files is a single line containing a comma separated list describing total number of frames, YOffset (for letterboxing), frames per second, path/prefix of raw image data. It is entirely possible to change this to a file on the fat:/ filesystem the flashcards use, and allow custom animations sequences to be loaded, but this would require a directory listing function which i do not have implemented yet. :\

Some notes: ø(._. )

  • Had to modify the font renderer just a bit to be compatible with C and not C++ styles. Would be nice to create a device driver within the devopt table so that stdio system may be used (ie: printf, putc calls etc) rather than font rendering specific calls.
  • Need moar animation loops to choose from (done but still need one more...)
  • Might add slider control on the screen to adjust pan, rotate, zoom, centering movement speed.
  • Mebbe start x,y centering to middle omyanimpl.aplf image by default.. would make some thing easier
  • Add slower bitrate mp3 for crappy cards??

More on all of this later...

Personal tools
irssi scripts
eggdrop scripts