Playing custom MP3 audios without uploading them

Also this is the python code:

# Libraries

import librosa
import numpy as np

File = "Audio.mp3"
SampleRate = 5000


# Audio

Data, Rate = librosa.load(File, sr=SampleRate, mono=True)
DataInt = np.int16(Data * 32767)

LuaTable = "local Samples = {" + ",".join(map(str, DataInt)) + "}"

with open("Audio_Samples.txt", "w") as TxtFile:
    TxtFile.write(LuaTable)
2 Likes

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?

1 Like

I am not sure, I am new to python and I used some ChatGPT’s help to make this python script.

1 Like

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.

2 Likes

@SirKhalidBlox You got this bro!

1 Like

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.

2 Likes

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

1 Like

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.

2 Likes

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?

1 Like

We do not have that kind of resource or any offering to help here.

Honestly man, I say just keep trying because if someones done it before even if the quality is bad you can too, good luck!

1 Like

That source is not verifiable, though. Not until something is found. :face_with_diagonal_mouth:

Thanks for answering, I think I might do some research and some attempts to make this work to see if it’s actually possible or not.

1 Like

You could make it as a MIDI player but I don’t think you can 1:1 replicate it as roblox doesn’t have the tools for it.

1 Like

If I recall correctly, you can not play audios on Roblox that aren’t uploaded. Please correct me if I could be wrong.

1 Like

If I removed the fps cap and managed to get it to about 3K fps, would that be able to play 3K samples per second?

There is a way to get 3k+ FPS by the way, here is a post about it: Creating the most optimized Roblox game- runs at 6000+ FPS!

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.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.