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
Android, Soundfonts pitch and playback issues #1783
Comments
I can confirm the issue using Csound for Android ver 39, library 6181, as well as with the Cabbage Android app. Using iflag = 1 and controlling the pitch with kfreq doesn't help. Purely synth patches seem OK, the problem seems to be with sample-based ones. Have tried using various sfinstr & sfplay opcodes as well as multiple sf2 files including the above mentioned and FluidR3_GM.sf2 The sf2 files play fine using the Fluid Synth Android app I have not yet tried the Csound fluid opcodes but am aware they apparantly can't be used with CsoundUnity. Edit: with the fluid opcodes, all tested sf2 files did in fact work correctly. |
I've moved to a new computer and currently unable to build Csound Android for Csound 6 or 7 and thus unable to diagnose this. I think @rorywalsh had mentioned he might take on Android maintenance. If so, could you perhaps take a look? |
Is this at all related to #1721 ? |
It could be related, but this one is Android only. I have the expected behaviour and output on Windows and Mac.
|
Ok. Just to clarify, because I am confused with the the other post in this issue:
One major difference is that Android is a floats build. Endianness is the same (?), but if that was a problem the sfont file would not even open. |
I can confirm from testing numerous sfonts, including the sf_GMbank.sf2
which is installed by the app, that the issues which appear specific to
Csound for Android involve pitch & some patches not playing at all.
I have used the same test files with the fluid opcodes & they play fine so
it seems to be an issue of using the sfplay/sfplay3 opcodes in Android.
Here's a simple ex:
<CsoundSynthesizer>
<CsOptions>
-odac
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1
gisf sfload "/sdcard/Music/Samples/sf_GMbank.sf2"
sfilist gisf
instr 1
inum init p4
ivel init p5
ivel init ivel/127
kamp linsegr 1, 1, 1, .1, 0
kamp = kamp/5000
kfreq init 1
a1,a2 sfinstr ivel, inum, kamp*ivel, kfreq, 0, gisf
outs a1, a2
endin
</CsInstruments>
<CsScore>
i1 0 .5 60 64
i1 + . 62
i1 + . 64
i1 + . 65
i1 + . 67
i1 + . 69
i1 + . 71
i1 + . 72
e
</CsScore>
</CsoundSynthesizer>
I believe Giovanni mentioned above that the pitch issues with sfplay in
Android don't occur in Windows or Mac using the same test files.
Unfortunately the fluid opcodes also appear to have issues on Android, such
as sound cutting out if one scrolls or types in the editor as a file is
playing, although all patches work and the pitch is correct.
…On Tue, Jan 2, 2024, 6:30 p.m. vlazzarini ***@***.***> wrote:
Ok. Just to clarify, because I am confused with the the other post in this
issue:
1.
Is this issue limited to the sfont opcodes (sfplay etc) or is this a
problem with the fluidsynth opcodes?
2.
Does it work correctly on Windows with no issues?
One major difference is that Android is a floats build. Endianness is the
same (?), but if that was a problem the sfont file would not even open.
—
Reply to this email directly, view it on GitHub
<#1783 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A23TOBR5QVOMC3JKPKAZ4WTYMSKBHAVCNFSM6AAAAAA7EHJ2GOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZUGY4DGOBSHE>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
ok thanks. At least with the sfont opcodes it's our own code so in theory we can fix it. I looked at the code and nothing jumps at me as a possible difference between Android and desktop. First I will need to confirm the issue is not present on the desktop. I will do that and report back. Then I will need someone who can build and test any changes I push as I don't have Android here. We'll get there. |
I can confirm that both @ST-Music latest example and the earlier example posted by @giovannibedetti work as I expect on my Mac using 6.18 (and they should work on 7, but since Android is in a bit of a disarray under develop, we'll debug this using 6.19 beta). I was listening to @giovannibedetti 's examples (from soundcloud and the CSD he posted) and I noticed that the patches seem to change quicker in the soundcloud example with the wrong pitches. Is that produced by the same CSD? The code to set the pitch does this (sfplay, splay3, sfinstr):
In performance, this frequency can be modulated by the xfreq parameter. So assuming, the data is correctly read from the sfont files, I can't really see that code executing differently on Android. Does that sound right? I may need to examine the file reading part. |
Ok I found a possible issue. Fine and coarse tuning settings were kept as I have pushed ceaad74 with a fix for this and it continues to work on MacOS. Now we need some brave soul to build from csound6 on Android to see if that made any difference. Any takers (@rorywalsh ?) |
Thanks so much for the investigation, I can try building for Android in a couple of hours and report back. |
I tried building but failed again on Windows. Unfortunately I'll have no other OS available for some days. If someone is able to build, I can test though! Just send me the /arm64-v8a/libcsoundandroid.so file and I'll be able to test using CsoundUnity |
Ok, I had a go and it wasn't too difficult to get the NDK and build Csound here: |
I updated the so lib on CsoundUnity and tried a quick Android build with the csd I posted in the first message. Still no improvements on the silent presets (almost all of them are silent), so I cannot really say if the pitch is fixed. One scale I could hear was correct (despite the fact that it skipped the first C note), but another preset was complete garbage. |
Could you try with the one from soundcloud? That one seemed to have all sounds loud and clear. The sf2 that comes with Csound was used I think. |
I will try later this evening! |
I recorded some videos on Windows (editor) and Android (with and without the fix), they can be found here.
For completeness, the list of the presets listed in the sound fonts: Presets
Preset list of "sf_GMbank.sf2"
Preset list of "07AcousticGuitar.sf2"
|
It seems we have a different issue? It would be better if we could tackle the pitch problem first, then move on to this. Is it possible to reproduce this? |
@giovannibedetti does the printed present list look exactly the same on Android and on Windows/Desktop? The selected sounds are not. For example preset 7 sounds different and preset 16 is also different (with weird tuning). I tested your CSD on MacOS and I hear different sounds from the few that work on Android. A first thought is that somehow volume is set to 0 on the silent ones, but it may also be that the selected presets are just empty. |
I still can't see what the issue can be with presets in particular. However, the unsigned/signed issue seems to be real, and I think I might not have fixed all of it in my first attempt. Could you try this new library file: |
FWIW, in the Android app all of the presets for sf_GMbank.sf2 play, just
not in tune. The issue seems to be related more to specific sf2 files. I
know Giovanni was having issues with the MuseScore_General.sf2. I tried it
and very few presets play.
I also tested the FluidR3_GM.sf2 and in that case most played but often
with certain individual notes not playing for some reason (perhaps related
to the running issue?).
I did notice in Caustic that some presets for the MuseScore show very
oddly. For example, the acoustic pianos don't appear as single presets,
they appear as numerous presets categorized by the dynamic range (MF, FF)
and brightness, see attached.
Out of curiosity, do the sfplay/sfinstr opcodes support sf3 files? I
suspect not. Apparantly it was created after the sf2 format was no longer
being developed by Emu/Creative.
Perhaps it's not coincidental that MuseScore is the company that developed
the sf3 and that is the primary sf2 file I've tried where patches don't
play. I do have several fairly large multi-layered piano and other sf2
files that play ok.
I don't know if you want to be bothered but the MuseScore sf2 I tried can
be found here:
https://ftp.osuosl.org/pub/musescore/soundfont/MuseScore_General/MuseScore_General.sf2
It's a little over 200mb.
There is a Readme.md as well:
https://ftp.osuosl.org/pub/musescore/soundfont/MuseScore_General/MuseScore_General_Readme.md
…On Sun, Jan 7, 2024, 12:31 p.m. vlazzarini ***@***.***> wrote:
I still can't see what the issue can be with presets in particular.
However, the unsigned/signed issue seems to be real, and I think I might
not have fixed all of it in my first attempt. Could you try this new
library file:
Uploading csound-android-80123.zip…
—
Reply to this email directly, view it on GitHub
<#1783 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A23TOBRQLWMMUUAC4GDCRDDYNLLYTAVCNFSM6AAAAAA7EHJ2GOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBQGEYTSOJZGI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@ST-Music did you try my latest build above? |
Thank you Victor. I'm sorry for the late reply, I'm travelling and I won't be able to test the build until tomorrow. |
Unfortunately I don't have a computer nor the skill to apply your build as
I only use the Android app and have limited programming skills beyond
Csound. So I wouldn't know what to do with the .so files.
Hopefully Giovanni can test & once it's working Michael Gogins can rebuild
the app.
Thanks for all the dev work, it is much appreciated.
…On Mon, Jan 8, 2024, 1:42 a.m. vlazzarini ***@***.***> wrote:
@ST-Music <https://github.com/ST-Music> did you try my latest build above?
—
Reply to this email directly, view it on GitHub
<#1783 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A23TOBTEPHADERSICPUVZ4DYNOIPDAVCNFSM6AAAAAA7EHJ2GOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBQGQ2TMOJQHE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I just tested the new build, the behaviour is the same as before. Full log here```2024/01/10 11:45:23.659 30317 30362 Info Unity CsoundUnity Awake
|
ok, presets seem to be there ok, so I have to check that the parameters are passed properly from file to memory. In any case, we should try focusing on one preset (e.g. the first one) and try to get it to play. |
So here's something to test. Using this code
can you test this lib: I have added some tracjing. So now you should get something like this for every note
It will be interesting to see what gets printed. |
I see these logs (no tracing), and no output: Details
2024/01/17 20:21:29.227 14587 14807 Info Unity SECTION 1: |
ok, then it does not look like the code is actually reaching the place where the soundfont data is read (assuming the Csound library is the one I sent you, could you check the build version and date? It should be 6.19 beta from today). |
You're right, it is still version 6.18. I'm not sure what I did wrong, I will try to reimport the libs in a few minutes. Logs
2024/01/18 10:10:55.000 12082 12209 Info Unity CsoundUnity Awake |
Ok I found the reason, I'm sorry for this! I was compiling against ARM7, and my ARM64 phone wasn't complaining. So all the tests above are to be considered void. |
Ok, now I'm using the right version: 2024/01/18 10:22:46.078 13061 13122 Info Unity Csound version: 6190, API Version: 400 but still I don't hear anything, and no further info from the logs. I'm using the last csd you posted. Details
2024/01/18 10:26:38.360 13955 14001 Info Unity orch now loaded |
So I tested again the csd that has the channel to change presets, and all is working as expected! I also have the expected logs now: Details
2024/01/18 10:36:39.299 14665 14689 Info Unity split: 0, samplebase:0xb4000074b739a5b8 freq: 261.625580 orig: 261.625580 So it looks like it is fixed! I will do some more testing, and I will try to understand why the other csd is not producing any output. |
Thanks. Two things:
For each note. The first line reporting about layers in preset will always print as this is seen at the top of sfplay3 init function. (2) In the example code I had
bring this to 100, so it doesn't interfere. |
Oh great, I prepared a new lib with more tracing (above) before I knew you had it running. Also: could you report back what you change to make it work? So we know and if there is anything to be fixed, we can do it? |
This csd has a velocity of 2 that is too low to hear anything (as you already noted). Setting it to a higher value makes it work as expected. The other thing I had to do is switch to IL2CPP as scripting backend (instead of using Mono) to be able to export for ARM64 devices and use the correct lib you sent (otherwise by default Unity for Android exports ARM7 builds, so it was using the 6.18 version dated 27oct 2022) I will do some more tests with different sound fonts later and report back here |
it's true about the vel of 2, I was messing with it and copied the code by mistake. OTOH I think that works on the desktop. |
I have tested several sound fonts, all looks good. Thanks for the fix, lots of people will be happy about this! csound\Android\CsoundAndroid\jni\Application.mk should be
|
I can do that. I think I actually have all of these, not sure of x86. I'll post it here. I think my original hunch about signed/unsigned discrepancies was correct. |
Here is the Android release package with these fixes |
I am experiencing a weird behaviour with Sound Fonts on Android. I have no issues with the same csd on a Windows machine.
I can replicate the issue with the soundfont used in the examples, sf_GMbank.sf2.
With this sound font, the pitch of the played notes behaves erratically and it's wrong for some notes.
With other sound fonts I tried (for example the MuseScore generic SF), most of the presets don't play at all.
This (zipped) csd shows the issue
TestSoundFonts_Android.zip
The issue may be related with the handling of presets, since soundfonts with a single preset don't have the same issue and play correctly.
Tested with the Csound for Android app (Csound 6.18.1), Cabbage for Android (Csound 6.08), and CsoundUnity 3.4.1 (Csound 6.18) (sorry but I failed to build the Android repo)
See this Cabbage thread for more info.
The text was updated successfully, but these errors were encountered: