Can I read each midi channel separately? #1577
Replies: 4 comments 3 replies
-
|
I seem to have gotten it working with I don't know if this is the intended way to do this or if its stupid and I should do something different. If someone more knowledgeable could take a quick look I'd greatly appreciate it :) Below is my code. (Apologies for using C#, I am running this in Unity) |
Beta Was this translation helpful? Give feedback.
-
|
Fluid_synth_process is the way to do it. Pls do yourself a favor and only
allocate a single native sample buffer as explained in the usage example:
https://www.fluidsynth.org/api/fluidsynth_process_8c-example.html#a0
Audio channels should be 16, see
https://www.fluidsynth.org/api/fluidsettings.xml#synth.audio-channels
Your code is currently lacking a lot error handling (null pointer after
new_fluid_*, fluid_failed).
Since you seem to be doing custom audio panning in your app, consider only
rendering either left or right channel by explicitly nulling the other
buffer, or by mixing both channels onto the same buffer (should work but i
cant remeber to have ever tested this).
When your game is ready and publicly available, feel free to list it here:
https://github.com/FluidSynth/fluidsynth/wiki/Applications
If your game is closed source pls ship fluidsynth as shared library,
https://github.com/FluidSynth/fluidsynth/wiki/LicensingFAQ
Message ID: <FluidSynth/fluidsynth/repo-discussions/1577/comments/13360309@
… github.com>
|
Beta Was this translation helpful? Give feedback.
-
|
Why not using a already made Unity package for this? There is a at least two free packages in the Unity store: |
Beta Was this translation helpful? Give feedback.
-
|
The array of float pointers that you pass to fluid_synth_process can all
point to different locations within the same sample buffer. The pointers
can also alias each other. I suggest you start to understand the simple
stereo use case followed by mono rendering before looking into multichannel
rendering. I am currently only available via mobile and unable to provide
c# examples. Im sure chatgpt would be helpful for you to understand it as
well.
…
Message ID: <FluidSynth/fluidsynth/repo-discussions/1577/comments/13369303
@github.com>
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there, I'm looking to use fluidsynth in a 3d game and would need to read the audio data for each channel separately so I can play it in 3d space for spatial audio. Is this possible with FluidSynth?
I've tried muting all channels and unmuting one at a time (with
fluid_synth_cc(channel, 7, 0)), then reading the data withfluid_synth_write_float(), but this creates distortions in the audio.My current plan would be to use multiple synths with one instrument each, but this of course would mean more cpu/ram usage. Is there a better approach to this?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions