JS RAM Player

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

janimatic
Posts: 136
Joined: Sat Mar 26, 2005 12:22 am
Contact:

JS RAM Player

Post by janimatic »

Hey!

i see LM just released the new moho version! I can't wait to try it..
At the same time i provide an image/audio player...
Only windows binaries for today (linux and mac will follow later) :

http://animatic.no-ip.com/pub/dev/moho/ ... er_0.1.zip

This is free (but closed...)

INSTALL :
unzip the file somewhere (ex : C:\\player\\)
There is a lua script called "js_ram_preview.lua"
Please edit this 2 lines to reflect your configuration :
(notice double back slash)
Fullpath to moho binary :
local mohoPath="D:\\Program Files\\Moho\\moho";
Directory containing player binary :
local playerPath="I:\\projets\\dev\\sdl\\sdltests\\player";
Place the lua script in your moho/script/menu directory
> It will ask you to select a moho project and an audio file
> It will create a render and a player script and run them
> run moho renderer (producing png sequences in a standard location)
(option to overwrite if images exist already)
> will lauch the RAM based player

TODO :
Work on audio seeking
and general image/audio sync
Message to Lost Marble :
It would be cool if i could access more variables from lua,
-to know the current project's file name
-to know the current audio file name
(that way no more need to select anything for user!)


Feedback very welcome!!!

PS:
thank you LM for the moho update it looks great!
User avatar
Lost Marble
Site Admin
Posts: 2347
Joined: Tue Aug 03, 2004 6:02 pm
Location: Scotts Valley, California, USA
Contact:

Post by Lost Marble »

I don't understand how to use this. When I run the script, it opens a Save File dialog and asks me to select an audio file. Should it be an Open File dialog?

Also, if I try to run the player by itself, it seems to be missing zlib1.dll.
janimatic
Posts: 136
Joined: Sat Mar 26, 2005 12:22 am
Contact:

Post by janimatic »

oops!

It was a wrong version of the lua script !
also i added the zlib.dll

Sorry
janimatic
Posts: 136
Joined: Sat Mar 26, 2005 12:22 am
Contact:

Post by janimatic »

also,
you can read the instructions in the included readme.txt
or at the bottom of this page :
http://animatic.no-ip.com/pub/dev/moho/js_player_0.1/
User avatar
Lost Marble
Site Admin
Posts: 2347
Joined: Tue Aug 03, 2004 6:02 pm
Location: Scotts Valley, California, USA
Contact:

Post by Lost Marble »

I'm still getting an error. On line 113 of js_ram_preview.lua:

local IMAGES_EXIST = JS.fileExist(imageFullName)

JS doesn't seem to exist anywhere as an object, and so the fileExist function can't be called and the script exits at that point.
janimatic
Posts: 136
Joined: Sat Mar 26, 2005 12:22 am
Contact:

Post by janimatic »

awww
excuse me

you need to add this file
http://animatic.no-ip.com/pub/dev/moho/ ... tility.lua

in your script/utility directory ...
User avatar
Lost Marble
Site Admin
Posts: 2347
Joined: Tue Aug 03, 2004 6:02 pm
Location: Scotts Valley, California, USA
Contact:

Post by Lost Marble »

I'm still having lots of problems with this utility. First, I finally got far enough that it creates the RENDER and PLAY batch scripts. (I'm not sure if I'm supposed to manually run these scripts, or if the Lua menu command is supposed to do it, but the scripts are currently broken.) However, there's a problem:

On the first line of the RENDER script, there should be quotes around the directory name. In my case, I'm trying to use a sample animation included with Moho. It's location is "C:\Program Files\Moho\..."

Your RENDER script creates two new directories called
C:\Program
and
Files\Moho\....
on my hard drive. I'm pretty sure this was not the intention. If I add quotes myself, then the RENDER script does in fact render out a result.

Next, the PLAY script. This script didn't work for me "out of the box". I think it may have been my mistake, but I'm confused here. When you edit the js_ram_preview.lua, are you supposed to enter the path to the player program, or the path to the directory containing the player program? I may have enterer the wrong path. I eventually got it working, but it's kind of confusing.

Finally, audio playback seems to have problems. In the file I used, the audio played back way too fast, like maybe twice the speed it should play at.
janimatic
Posts: 136
Joined: Sat Mar 26, 2005 12:22 am
Contact:

Post by janimatic »

wow

i feel like shame...
As you said the broken path are quotes issues
And the way to configure player and moho location is not consistant enough, that confusing indeed.. but all this is easy to fix.
The really bad point is about audio speed .
I am not (yet) acting on audio speed (it's in a separate thread but i don't control the rate) So i guess i should check some sampling rate parameter ...
Will test it with unusual sampling rates (can you send me the audio file ?)

Anyway thank you very much for the feedbacks it's very encouraging :)
janimatic
Posts: 136
Joined: Sat Mar 26, 2005 12:22 am
Contact:

Post by janimatic »

When you edit the js_ram_preview.lua, are you supposed to enter the path to the player program, or the path to the directory containing the player program?
Fullpath to moho binary :
local mohoPath="D:\\Program Files\\Moho\\moho";
Directory containing player binary :
local playerPath="I:\\projets\\dev\\sdl\\sdltests\\player";
yes sorry about that but for today mohoPath is complete path
while playerPath is path to directory containing player.exe
I'll put the configuration variables in a separate place with a consistant logic
janimatic
Posts: 136
Joined: Sat Mar 26, 2005 12:22 am
Contact:

Post by janimatic »

the audio played back way too fast
i guess it should work if you try with a 16 bit 44100 hz stereo file..
I hardcoded this values [will fix that]
So i guess you did the test with a 22 khz file?
User avatar
7feet
Posts: 840
Joined: Wed Aug 04, 2004 5:45 am
Location: L.I., New Yawk.
Contact:

Post by 7feet »

If you need to check anything in a WAV file (includes MP3's with WAV headers) this is the header definition, first number is byte offset, second byte length of the info.

0 4 RIFF -- little endian uses RIFX
4 4 LOF - chunksize of entire file (36 + subchunksize2)
8 4 WAVE
12 4 fmt<space>
16 4 Subchunk1Size (16 as number for PCM -standard) - 50 for lwv
20 2 audio format - 1 for uncompressed
22 2 number of channels - 1 or 2
24 4 sample rate
28 4 ByteRate = SampleRate * NumChannels * BitsPerSample/8
32 2 BlockAlign = NumChannels * BitsPerSample/8
The number of bytes for one sample including
all channels.
34 2 Bits per second
36 4 DATA
40 4 Subchunk2Size = NumSamples * NumChannels * BitsPerSample/8
This is the number of bytes in the data

44 THE SOUND

These are the codes for the various possible formats inside a wave, if you need them:

0 (0x0000) Unknown
1 (0x0001) PCM/uncompressed
2 (0x0002) Microsoft ADPCM
6 (0x0006) ITU G.711 a-law
7 (0x0007) ITU G.711 µ-law
17 (0x0011) IMA ADPCM
20 (0x0016) ITU G.723 ADPCM (Yamaha)
49 (0x0031) GSM 6.10
64 (0x0040) ITU G.721 ADPCM
80 (0x0050) MPEG (MP3)

Might help you sort things out a little.
janimatic
Posts: 136
Joined: Sat Mar 26, 2005 12:22 am
Contact:

Post by janimatic »

thank you Brian!

i hope (well, i believe) my libs will save me from going so deep in wav file format (it also deals with other formats)
It's always good to know how things work really when you are doing crossplatform developpement though!
janimatic
Posts: 136
Joined: Sat Mar 26, 2005 12:22 am
Contact:

Post by janimatic »

oops double post..
User avatar
7feet
Posts: 840
Joined: Wed Aug 04, 2004 5:45 am
Location: L.I., New Yawk.
Contact:

Post by 7feet »

Well, the one thing I thought might be useful would be checking just the sample rate directly. It's pretty foolproof if you are having any problems, if you have a way of forcing the playback to a particular sample rate.
User avatar
Lost Marble
Site Admin
Posts: 2347
Joined: Tue Aug 03, 2004 6:02 pm
Location: Scotts Valley, California, USA
Contact:

Post by Lost Marble »

janimatic wrote:So i guess you did the test with a 22 khz file?
It certainly could be, but I'm sorry to say I don't actually remember which audio file I used. I just picked one at random from my audio test folder.
Post Reply