The Dink Network

Is it possible...

December 20th 2003, 02:21 AM
spike.gif
...to play a midi non-stop? You know, without any "darn gaps"?
December 20th 2003, 07:12 AM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
No, that's impossible. You could write a loop to wait the length of the midi, but when you go into your inventory, the midi continues, but the loop stops.

The only way to make a sound play really non-stop is to make it a wav and enable looping in the play_sound command, I guess.
December 20th 2003, 07:57 AM
custom_king.png
redink1
King He/Him United States bloop
A mother ducking wizard 
loop:
playmidi("101.mid");
wait(500);
goto loop;

There is a slightly better and more intuitive way... I think I did it in COE.
December 20th 2003, 12:32 PM
anon.gif
Beuc
Ghost They/Them
 
Check my first reply, point 4), at http://www.dinknetwork.com/archives/prowler/posts/000435.html

December 21st 2003, 01:22 AM
spike.gif
I was afraid so. Guess I have to manage with wavs then. Do wavs loop just by attaching a sound to a sprite? (e.g. sp_sound(&current_sprite, 50); ) or does it require some extra mumbo-jumbo? (Never tested this in practise)

And...mm...a sound DOES survive map change just by adding script_attach(1000); right?

BTW, redink, you should have a show emoticons in posts checkbox somewhere.

EDIT: Why, oh WHY does &curren change into an ¤ when editing a post?
December 21st 2003, 09:08 AM
custom_king.png
redink1
King He/Him United States bloop
A mother ducking wizard 
There are several types of numbers in Dink:

Sprite Editor Number: the number of a sprite in map.dat that you placed in DE or WDE.

Sprite Number: a number of a currently active sprite. Examples include 1 (Dink), ¤t_sprite, etc.

Script Number: each script that is being run is assigned its own unique number. This isn't used that much, except for run_script_by_number, and you can get the script number from the return value of spawn (I think, anyway) and ¤t_script.

Sound Index Number: usually defined in start.c, it assigns a sound file to a value to be used with playsound.

Sound Number: each sound that is played has its own unique number, by which you can tell it to loop, change its volume, and kill it. You get it from the return value of playsound.

So, as a long way to answer your question, sp_sound(¤t_sprite,50); wouldn't work for between screens, and script_attach(1000); wouldn't work at all because it only deals with the ¤t_script value.

In order to do it, you'd need to do something like this:

//Let's make a global variable called mysound
make_global_int("&mysound",0);

//The last number in the playsound command instructs Dink to loop the sound.
&mysound = playsound(50,16025,0,0,1);
sound_set_survive(&mysound);

//If you want to kill the sound, do this
sound_set_kill(&mysound);

But anyway... try the looping midi thing. Unless you absolutely need the music to loop for every single second. If the user goes into the Inventory screen for a couple hours, the midi will begin when the go back into the game and so on.
December 21st 2003, 10:52 AM
spike.gif
No, I'm stubborn. I want it to repeat with absolutely no gap.

Anyway, what was the command to turn midi off? simply turn_midi_off(); ??? (I'm way too lazy to download any command list thing here, and the original that came with Dink Smallwood has propably been deleted)
December 21st 2003, 11:05 AM
fish.gif
Simeon
Peasant He/Him Netherlands
Any fool can use a computer. Many do. 
Directly from DinkC Reference:

stopmidi() (stop a playmidi() playback)
turn_midi_off() (turn off midi attached to screen)