Hello, I am trying to play a custom MP3 Audio in Roblox, I don’t know if this is against the rules or not, because I heard that some people did it before, I just want to make this for testing, If it is against the rules please tell me.
I tried making a looped sound of 440 hertz then changing the audio’s pitch and volume to make it sound like the MP3 file, but I don’t think that worked, this is my code:
game["Run Service"].Heartbeat:Connect(function()
if index <= #samples then
local sample = samples[index]
local amplitude = math.abs(sample / maxAmplitude)
Sound.Pitch = 1 + (sample / maxAmplitude)
Sound.Volume = amplitude * 100
index += 1
else
index = 1
end
print(index)
end)
I used a python script I made to turn Audio files to sample Lua tables.
Wait I dont have a solution but this is very interesting so you give the python script an MP3 and it what, converts it to something that lua can parse and playback using a Sound instance, does this work for every type of audio?
Unfortunately, playback like these are nearly impossible and impractical within engine limitations. It is way too slow to catch up to the samples the audio contains and do not have dedicated API to manage that.
You also can’t play custom audio as a whole concept here, given that the tool can be used maliciously. There would be problems with the Terms of Use and Community Standards. That’s the worst case scenario.
On the other hand, I haven’t seen any interfacing between other languages directly from the engine. It always goes indirectly through HttpService and there will be a noticeable delay in the interactions.
I am pretty sure I heard that people have done this before, even if the quality is bad I just want it to be hearable, and I don’t think I will be publishing this or using it any any public game, if I do I will not play anything against the rules.
Actually, you’re not reviewing the entire picture of this. The whole other problems and hinderances between are more noteworthy to mention that it will make it impossible.
You’re a composer could you explain like how this would actually work though behind the scenes because Im a bit confused how MP3 audios or even other audio files allow us to hear sound
I doubt there’s enough audio data to actually cover all the playbacks, really. Sounds that are complicated are actually made out of multiple layers of different waveforms. Discerning their waveforms is what makes the process impossible.
Audio files contain a range of sample points which contain data of both amplitudes, pitch, panning, you name it. Depending on the sample rate(44.1kHz and 48kHz are common). The samples are processed to a playback which makes up the sound we hear. The sample rate is per second which means a lot of sample points.
Actually, I think the sample points are more likely to contain the “polarity”. The more they cross the zero threshold, a sound is played. These polarities are by extension properties to the other auditory properties.
The reason I am attempting to make this is because it has been done before, I unfortunately couldn’t find the post that was talking about this, Also even if the audio is distorted and is very bad, I just want it to be hearable and that you could actually atleast recognize the audio, do you have any post/tutorial that could help me try to make this?
After many attempts and a lot of research, I think this is actually impossible, I might try to do this in the future if Roblox made an update that would make this actually possible.