Can you make duplicates of IGModAudioChannel?

I am working with the sound.PlayURL stuff and the 3D sounds it can do, especially with streamed audio. However, I realized that if I added another sound.PlayURL in the mix with the same stream URL, there would be roughly a 1 second delay between the two sound sources. Is it possible to use the first sound.PlayURL channel for the second one, that way the stream would be Nsync (:suicide:) with any other channels I want to stream from the same URL?

Ex:
[lua]
sound.PlayURL(“http://www.musicplace.com/listen.pls","3d”,
function(channel)
//I want to copy the channel object somehow so I can use it’s stream in another position in the world
channel:SetVolume(1)
channel:SetPos(Vector(1,1,1))
end
)
[/lua]

Bump

This is just something that came out on the top of my head without any testing, but you might be able to make a cache system and call :Pause and :Play in sync when needed



local cache = {};
local used = {};
local cacheamt = 20;

local function CacheSound(i)
	sound.PlayURL("http://www.musik.de.com.co.uk/musik.mp8", "SOUND:DD"..i, function(channel)
		cache* = channel;
		channel:SetVolume(1);
		channel:SetPos(Vector(0, 0, 0));
		channel:Pause();
	end)
end

for i = 1, cacheamt do
	CacheSound(i);
end

local function PlayCachedSounds(tpos)
	for i = 1, #tpos do
		used* = cache*
		used*:SetPos(tpos*);
		used*:Play();
		CacheSound(i);
	end
end


then call



PlayCachedSounds({Vector(1337,1373,1733), Vector(1733, 1373, 1337)});


I don’t think that will work for streaming stations. I was thinking of something along the lines of being able to utilize the same stream somehow, not having to open a new stream connection for each sound. But, if it were mp3 or other recorded audio, I think your method would work.

Pausing as far as I know doesn’t stop the stream, but even if it did stop the stream, it would have to catch up again, and most likely put me back to square one.

You could cache sounds on the client via text-files. If it can be done for images, then the same may be possible for audio files.

If it’s an actual live-stream, for it to save properly, as audio, you’d have to figure out the proper header and footer for the audio. To play it, you’d need to grab the data itself, and then force that to play.

HTML panels could be useful for this; as png images can be displayed albeit stored in text files like so:

[lua]local _html_code = “<!DOCTYPE html><html><body><img src=“data:image/png;base64,” … _encoded … “” height=”" … tall … “” width="" … wide … “”></body></html>"[/lua]

The same may be possible for audio files; only try this if the other way doesn’t work, putting data directly into the function, or trying to run the txt file as the path of the file. This will create more over-head, but you could do it in a way that it’s part of the clients global vgui and opened on start. You could have multiple elements triggered by JavaScript to play sounds this way.

I’m not really looking to play sound effects, which (if I am wrong, sorry) is what it sounds like you’re getting at. I have a Shoutcast server streaming music to clients, and they can chose what station they would like to listen to. However, when there are multiple sources in the world playing the same station, they should (ideally) be synced. But, with the way that sound.PlayURL works, there is a new stream opened for each sound sources, which leads to unsynced sound.

You may be able to do something similar to what rendering multiple clientside models would look like.

Example: Keep a list of audio playing on the client; keep it client-only, don’t let the server play the audio. Next, have the sound rapidly change between two positions if it’s playing the same station, and they’re within earshot. This may or may not have the effect you want. You may need two channels open, but try that and see if it works.

Maximum of one stream per url open, move it around.

It was a good idea, but it was horribly choppy sounding. I used a Think hook to toggle between two positions every think, not far away from each other, and it could be heard, but it was just choppy.

Bad idea then; I was hoping that if done quickly enough it would sound smooth. I do some things with sound but not with play URL.

I then build the sound-table and CreateSound, storing everything in the same table so it’s only setup once. I do copy the sounds to each vehicle though; so that might be the missing link.

Add me on Steam, I may be able to help. I’ll run some tests in a little-bit on the play url system.

Added.