Извините, ничего не найдено.

Не расстраивайся! Лучше выпей чайку!
Регистрация
Справка
Календарь

Вернуться   forum.boolean.name > Программирование игр для мобильных телефонов > MidletPascal

Ответ
 
Опции темы
Старый 06.12.2010, 14:41   #1
NastyKhan
Оператор ЭВМ
 
Регистрация: 26.09.2010
Сообщений: 29
Написано 0 полезных сообщений
(для 0 пользователей)
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
(Offline)
 
Ответить с цитированием
Старый 06.12.2010, 16:12   #2
GaisinPro
AnyKey`щик
 
Регистрация: 06.12.2010
Сообщений: 2
Написано одно полезное сообщение
Ответ: 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;
Учи Великий и Могучий )))
(Offline)
 
Ответить с цитированием
Старый 06.12.2010, 16:41   #3
ViNT
Модератор
 
Регистрация: 03.04.2007
Сообщений: 2,252
Написано 597 полезных сообщений
(для 817 пользователей)
Ответ: 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.
(Offline)
 
Ответить с цитированием
Старый 07.12.2010, 00:24   #4
NastyKhan
Оператор ЭВМ
 
Регистрация: 26.09.2010
Сообщений: 29
Написано 0 полезных сообщений
(для 0 пользователей)
Ответ: 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?)
(Offline)
 
Ответить с цитированием
Старый 07.12.2010, 01:31   #5
ViNT
Модератор
 
Регистрация: 03.04.2007
Сообщений: 2,252
Написано 597 полезных сообщений
(для 817 пользователей)
Ответ: 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 Посмотреть сообщение
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.
(Offline)
 
Ответить с цитированием
Старый 07.12.2010, 17:14   #6
NastyKhan
Оператор ЭВМ
 
Регистрация: 26.09.2010
Сообщений: 29
Написано 0 полезных сообщений
(для 0 пользователей)
Ответ: 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?
(Offline)
 
Ответить с цитированием
Старый 07.12.2010, 18:18   #7
ViNT
Модератор
 
Регистрация: 03.04.2007
Сообщений: 2,252
Написано 597 полезных сообщений
(для 817 пользователей)
Ответ: Vibra, Data, Midi

Do you load file once, or you use OpenPlayer every time, when you call StartPlayer?
(Offline)
 
Ответить с цитированием
Старый 07.12.2010, 20:53   #8
NastyKhan
Оператор ЭВМ
 
Регистрация: 26.09.2010
Сообщений: 29
Написано 0 полезных сообщений
(для 0 пользователей)
Ответ: 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..
(Offline)
 
Ответить с цитированием
Старый 07.12.2010, 22:22   #9
ViNT
Модератор
 
Регистрация: 03.04.2007
Сообщений: 2,252
Написано 597 полезных сообщений
(для 817 пользователей)
Ответ: 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 .
(Offline)
 
Ответить с цитированием
Старый 07.12.2010, 23:13   #10
NastyKhan
Оператор ЭВМ
 
Регистрация: 26.09.2010
Сообщений: 29
Написано 0 полезных сообщений
(для 0 пользователей)
Ответ: Vibra, Data, Midi

Sounds exactly what i am looking for. Where can i get it?
(Offline)
 
Ответить с цитированием
Старый 07.12.2010, 23:15   #11
ViNT
Модератор
 
Регистрация: 03.04.2007
Сообщений: 2,252
Написано 597 полезных сообщений
(для 817 пользователей)
Ответ: Vibra, Data, Midi

Сообщение от NastyKhan Посмотреть сообщение
Sounds exactly what i am looking for. Where can i get it?
The library is here
(Offline)
 
Ответить с цитированием
Старый 07.12.2010, 23:21   #12
NastyKhan
Оператор ЭВМ
 
Регистрация: 26.09.2010
Сообщений: 29
Написано 0 полезных сообщений
(для 0 пользователей)
Ответ: Vibra, Data, Midi

Thanks. Sorry for not using 'search button' but u know.. the whole forum is in russian anyway
(Offline)
 
Ответить с цитированием
Старый 08.12.2010, 01:26   #13
NastyKhan
Оператор ЭВМ
 
Регистрация: 26.09.2010
Сообщений: 29
Написано 0 полезных сообщений
(для 0 пользователей)
Ответ: 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.
(Offline)
 
Ответить с цитированием
Старый 08.12.2010, 02:11   #14
ViNT
Модератор
 
Регистрация: 03.04.2007
Сообщений: 2,252
Написано 597 полезных сообщений
(для 817 пользователей)
Ответ: 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).
(Offline)
 
Ответить с цитированием
Старый 08.12.2010, 20:59   #15
NastyKhan
Оператор ЭВМ
 
Регистрация: 26.09.2010
Сообщений: 29
Написано 0 полезных сообщений
(для 0 пользователей)
Ответ: Vibra, Data, Midi

Success! 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..
(Offline)
 
Ответить с цитированием
Ответ


Опции темы

Ваши права в разделе
Вы не можете создавать темы
Вы не можете отвечать на сообщения
Вы не можете прикреплять файлы
Вы не можете редактировать сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.


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


vBulletin® Version 3.6.5.
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Перевод: zCarot
Style crйe par Allan - vBulletin-Ressources.com