ID:134657
 
If I use length() on a /sound datum, will I get the length of the song?

Let's say I want to be able to play a song, and want all of the online players to hear the song at the EXACT position it's on.

For instance, let's say I have background music. Player A would hear it when he logs in. Then, Player B logs in. Player B hears it as well, but from the beginning. What I want it to do, is create a global /sound datum. Whenever someone logs in, they'll hear the background song exactly as others hear it.

And what does "streaming" do? Does it provide you with this feature? And if so, how would I use it properly?
length() would return the file's number of bytes, I believe.
Channel might help you: src<<sound(channel=1)
In response to Artemio
Artemio wrote:
length() would return the file's number of bytes, I believe.
Channel might help you: src<<sound(channel=1)

How will the channel help me? I want to be able to determine for how long a song has been playing, determine how much time the song consists of, and to be able to set the time of a song so it'll play on another time.

Example:
var/songa
mob/verb/playsonga()
songa=sound('songa.ogg')
songa.channel=1
world<<"This song is [songa.songtime] milliseconds in time."
world<<songa
sleep(songa.songtime)
if(songa.playing) //why isn't this variable added? How do I check this?
world<<"This song has finished playing."
if(songa.songtime>=600)
world<<"You will now hear the song from the 1st minute on."
songa.time=600
world<<songa
else world<<"This song does not last a minute, so it won't replay from the first minute."
mob/verb/stopsonga()
world<<sound(null,1)


In this case, "songa" would be played to the world. If it's length is above a minute, at the end of the song, it will play from the first minute on. If stopped, it won't alert or replay.
In response to Qwerty2029
"Whenever someone logs in, they'll hear the background song exactly as others hear it."
Could play the channel to the target when they log in.
In response to Artemio
Artemio wrote:
"Whenever someone logs in, they'll hear the background song exactly as others hear it."
Could play the channel to the target when they log in.

<insert confusedness here>
Explain, please.
In response to Qwerty2029
mob
Login()
src << sound(channel=1)
..()


That SHOULD play the song on channel 1 to the player from the song's current position.
Qwerty2029 wrote:
If I use length() on a /sound datum, will I get the length of the song?

Of course not. The length() proc is designed for only text, files, and lists.

Lummox JR
In response to Nadrew
Nadrew wrote:
> mob
> Login()
> src << sound(channel=1)
> ..()
>

That SHOULD play the song on channel 1 to the player from the song's current position.

Actually since you didn't specify a file, that'll stop whatever sound is playing on channel 1.

Lummox JR
In response to Lummox JR
Oh, my bad -- I was thinking of another method but I forgot what =D. You can set a global variable to match the sound datum used for playing the song and output that variable to people logging in.
var
sound
current_song

mob
verb
PlaySong(S as sound)
if(current_song)
world << sound(null,channel=1) // Stop the music!
current_song = sound(S,1,channel=1)
world << current_song


Login()
src << current_song
..()


That should work.
Qwerty2029 wrote:
If I use length() on a /sound datum, will I get the length of the song?

Let's say I want to be able to play a song, and want all of the online players to hear the song at the EXACT position it's on.

For instance, let's say I have background music. Player A would hear it when he logs in. Then, Player B logs in. Player B hears it as well, but from the beginning. What I want it to do, is create a global /sound datum. Whenever someone logs in, they'll hear the background song exactly as others hear it.

That's not posible with the current state of the sound datum. you can't even be certain when Player A and Player B will finish hearing the song if you send the song to them at the same time, because download time and CPU load could slow it down differently for each player.

You can use the wait var for /sound on a specific channel to set up a playlist on a that channel that plays one after another, but that's the best you can hope for at the moment.


And what does "streaming" do? Does it provide you with this feature? And if so, how would I use it properly?

Streaming causes Dream Seeker to read the sound from disk instead of loading the entire thing into memory. Streaming frees up a lot of RAM, but you can't play that sound multiple times at once nor can you reverse playback. Streaming is ideal for background music, but ill suited for things like battle noises and interface beeps.

Whether it's created as streaming or not, the sound must be downloaded by the client before it can be played. it is not streamed over the internet.