Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /storage/content/49/145849/famitracker.com/public_html/forum/classes/dbHandler.php on line 29 FamiTracker
Login:
Menu:
Post: Author:
FamiTracker > General > Source and development > Text reader C++ Owner: rainwarrior New post
Page 1 of 1 Sort:  
Text reader C++ Posted: 2013-03-24 22:36  (Last Edited: 2013-03-26 00:14) Reply | Quote
rainwarrior

Avatar

Member for: 4150 days
Location: Canada
Status: Offline

#45819
I thought I'd share the code I used to make [url=http://www.youtube.com/watch?v=7kHKkwZTtdc]my latest animation.

Basically I make a text export, then with this code I do something like:

FamiText ftm;
ftm.read("some_ftm.txt");
ftm.play();

It doesn't read instruments or support tempo other than 150, but it's capable of playing back the FTM and you can check each frame if new notes were played.

For instance, if running the video at 30hz, I do this each frame:

ftm.tick(2);
FamiText::Cell square1 = ftm.read_tick(0);
FamiText::Cell square2 = ftm.read_tick(1);
FamiText::Cell triangle = ftm.read_tick(2);
FamiText::Cell noise = ftm.read_tick(3);
FamiText::Cell dpcm = ftm.read_tick(4);
if (square1.note >= FamiText::NOTE_C0)
{
// animate a new note
}
// etc.

The tick() function executes 1 or more 60hz frames, and the notes are consolidated if there is more than 1 frame, so for 30hz video I want tick(2) so that it will read a note if one happened on either of the last two 60hz frames. This makes it pretty easy to create animation reactions based on notes in an FTM.

Anyhow I just though I'd share in case it's useful to anybody else. It'd be easy to extend to read instrument macros and other things.


Attachments:
famitext.cpp (9 Kb)
famitext.h (1 Kb)
Posted: 2013-03-25 00:44 Reply | Quote
jsr
Administrator

Avatar

Member for: 5925 days
Location: Sweden
Status: Offline

#45826
This is neat, thanks for sharing.

Nice cover too.

_______________________
Programmer and developer
Posted: 2013-08-01 20:28 Reply | Quote
rainwarrior

Avatar

Member for: 4150 days
Location: Canada
Status: Offline

#50188
I can't edit my original post, but here's a revised version that now supports tempo (same algorithm as Famitracker, so it should match perfectly).


Attachments:
famitext.cpp (9 Kb)
famitext.h (1 Kb)
Page 1 of 1 Sort: