forum.boolean.name

forum.boolean.name (http://forum.boolean.name/index.php)
-   MidletPascal (http://forum.boolean.name/forumdisplay.php?f=46)
-   -   Vibra, Data, Midi (http://forum.boolean.name/showthread.php?t=13845)

NastyKhan 06.12.2010 14:41

Vibra, Data, Midi
 
Hello,
I almost finished my greatest invention, but i still need some things:

1. How to unleash vibra? Are there any special libs? Or just commands?
2. How to save data to a file? (to make high score or config file)
3. How to play MIDI music or MIDI sound effects from files?

Thanks

GaisinPro 06.12.2010 16:12

Ответ: Vibra, Data, Midi
 
1) Lib_vibra
function Vibrate(integer i); //i millisec
2) Lib_Resloader

3)
Код:

  if not OpenPlayer('/music.mid', 'audio/midi') then // load music
    Halt; // error
  if not SetPlayerCount(-1) then  Halt;
  if not StartPlayer then    Halt;
   
  // bla-bla-vla

  StopPlayer;

Учи Великий и Могучий )))

ViNT 06.12.2010 16:41

Ответ: Vibra, Data, Midi
 
Lib_resloader hasn't functions for saving data, it only can load data from resources.

If you need to save data to the phone's file system, you should use Lib_jsr75. Note, that using this library you may get a lot of troubles with different filesystems, security settings, etc.
If you need use saved data only in your midlet, it will be better to use RecordStore, that allow you easily save your data to the system registry independently of phone model and security policy. To get information about RecordStore, refer to standard MP help.

NastyKhan 07.12.2010 00:24

Ответ: Vibra, Data, Midi
 
Thanks.

About problem 2. Can I just write:

OpenPlayer('/music.mid'
StartPlayer;
StopPlayer;

?


And Vint, does saving highscore in registry can be dangerous to phone? (i mean - can it mess up something?)

ViNT 07.12.2010 01:31

Ответ: Vibra, Data, Midi
 
You should just write
Код:

if not OpenPlayer('/music.mid', 'audio/midi') then
    Halt;
  if not SetPlayerCount(-1) then  Halt;
  if not StartPlayer then    Halt;

and playing wil be started.
To stop player (i.e. by a timer) you should call StopPlayer.

Цитата:

Сообщение от NastyKhan (Сообщение 171216)
And Vint, does saving highscore in registry can be dangerous to phone? (i mean - can it mess up something?)

No, it is completely safe, because data is written to the local midlet's registry and don't influence on the system or another midlets.

NastyKhan 07.12.2010 17:14

Ответ: Vibra, Data, Midi
 
Vibra works fine, thanks.

Sound system works but.. it slows down an application greatly. I mean, my midi file consist of 1 note only (it's 114B ) but each time the program reaches the sound command, it stops for about 0.5s to load it. It makes game unplayable. The problem appears in both phone and KEmulator. Any hints?

ViNT 07.12.2010 18:18

Ответ: Vibra, Data, Midi
 
Do you load file once, or you use OpenPlayer every time, when you call StartPlayer?

NastyKhan 07.12.2010 20:53

Ответ: Vibra, Data, Midi
 
Actually i'm using OpenPlayer every time, because i'd like to play more than just one type of MID, and it looks like there are not.. "bufforing system" here to predefine all files before gaming. But i might be wrong..

ViNT 07.12.2010 22:22

Ответ: Vibra, Data, Midi
 
If you have not too much sounds, try to use Lib_player. It allow you to load some sounds simultaneously, and play any of it at the necessary time (even simultaneously, if phone supports audio mixing) without large delays .

NastyKhan 07.12.2010 23:13

Ответ: Vibra, Data, Midi
 
Sounds exactly what i am looking for. Where can i get it?

ViNT 07.12.2010 23:15

Ответ: Vibra, Data, Midi
 
Цитата:

Сообщение от NastyKhan (Сообщение 171314)
Sounds exactly what i am looking for. Where can i get it?

The library is here

NastyKhan 07.12.2010 23:21

Ответ: Vibra, Data, Midi
 
Thanks. Sorry for not using 'search button' but u know.. the whole forum is in russian anyway ;)

NastyKhan 08.12.2010 01:26

Ответ: Vibra, Data, Midi
 
After some experimenting i still can't figure out, how to this thing works. I'm basing on this example i found inside the zip:

program test11111;
uses player;
procedure player_event(p:integer; e:String);
begin
Debug(e+':'+p);
end;
begin
player.init(2);
if not OpenPlayer('/message.mid', 'audio/midi') then Halt;
if not SetPlayerCount(-1) then Halt;
player.set_listener;
if not StartPlayer then Halt;

player.select(1);
if not OpenPlayer('/online.mid', 'audio/midi') then Halt;
if not SetPlayerCount(-1) then Halt;
player.set_listener;
if not StartPlayer then Halt;

Delay(5000);

drawText('Hello world!', 0, 0);
repaint;
delay(2000);
end.


And hell.. Don't get it. What is the point of 'player_event' procedure if it's never called? And why sim doesn't run when I remove it? Also which commands are responsible for loading files, which for declaring vars, and which for calling? What is .set_listener? I'm sorry but i will need some more clues or something.. easier to use.

Could u give another example please? And point 'this is were we load files', 'this is were we name vars' and 'this is how we call previously redefined sounds'..

Pls help.

ViNT 08.12.2010 02:11

Ответ: Vibra, Data, Midi
 
The player_enevt proc is an event handler and is called by the library if any player event, like end of media, occur. It should NOT be renamed or removed, becaus it cause application error.

In the beginning we mus initialize the library, defining necessary count of players (equals to the count of sounds)
init(n); n - players count
after this operation library is initialized, and player, assigned with index "0" is selected.

After that, any standard player function (OpenPlayer, StartPlayer, SetPlayerCount will be applied to it, so, writing
if not OpenPlayer('/message.mid', 'audio/midi') then Halt; we load the file to the player "0". Calling set_listener, we assign event handler (the player_event proc) to this player.

To work with another player(1..n-1) we should call player.select(i), where i is index of the necessary player, after that all functions will be applied to player, indexed as "i" (but event handler continues to work for any player, for which set_listener was called).

NastyKhan 08.12.2010 20:59

Ответ: Vibra, Data, Midi
 
Success!:super: Sound system works.

However, after implementing sounds to the midlet the "MIDletPascal" application itself crash sometimes when I press 'build' right after 'save'. But it's nothing. I just have to turn on the application again, and at second time 'build' button works. Pretty odd however.

Thanks.

So all it's left for now it's highscore storage. First I'll try to figure it out by myself..


Часовой пояс GMT +4, время: 10:19.

vBulletin® Version 3.6.5.
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Перевод: zCarot