-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot pass an inputstream to Libgdx classes without touching the hard disk. #7400
Comments
Hi,
I never did this/tested this, but I guess you can just implement your own |
A |
That won't work because there's no way to modify the pitch for that. |
@Daburnell112 It looks like there is a class called FileHandleStream which is intended for this purpose. It does create a file when constructing the object (I think), but you don't need to write to it. Just store the InputStream in memory and use that. try (FileHandle handle : new FileHandleByteStream("foo.bar", new ByteArrayInputStream(myBytes)) {
Sound sound = audio.newSound(handle);
} public class FileHandleByteStream extends FileHandleStream implements AutoCloseable {
private final InputStream data;
public FileHandleByteStream(String path, InputStream data) {
super(path);
this.data = data;
}
@Override
public InputStream read() {
return data;
}
@Override
public void close() throws Exception {
data.close();
}
} |
There kind of is. |
The difficulty involved in doing this is substantial. I wouldn't expect anyone to write a pitch-shifting algorithm for a unique case without a series of spikes. |
I want to pass raw audio I am generating from an AudioInputStream to a Sound so that I can modify the pitch as I play it.
There's only one workaround for this, and it's writing to a temporary file on the hard disk resulting in tons of lag in the audio:
This leads to a bigger concern, and that is there's no way in general to create LibGDX class files (Anywhere that requires a call to Gdx.files.internal/local/etc) and modifying the data in RAM without first writing to the hard disk temporally, then loading that afterwards.
Ideally I'd have constructors that would allow you to pass InputStream instead of files (per every example in StackOverflow) that allow me to create classes like Sound or Texture that way.
If there's a workaround, let me know.
The text was updated successfully, but these errors were encountered: