kshoji / jfugue-for-android Goto Github PK
View Code? Open in Web Editor NEWMusic library JFugue porting for Android
Music library JFugue porting for Android
Can you please elaborate on how to initialize an Android project using your project?
Thank you for your work!
Update codes to JFugue version 5.0.
Hi! I am trying to use the Jfugue on Android, but I am getting this error:
java.lang.NoClassDefFoundError: Failed resolution of: Ljp/kshoji/javax/sound/midi/MidiSystem;
at org.jfugue.player.SequencerManager.getDefaultSequencer(SequencerManager.java:55)
at org.jfugue.player.SequencerManager.<init>(SequencerManager.java:50)
at org.jfugue.player.SequencerManager.getInstance(SequencerManager.java:41)
at org.jfugue.player.ManagedPlayer.<init>(ManagedPlayer.java:47)
at org.jfugue.player.Player.<init>(Player.java:46)
at org.jfugue.midi.MidiFileManager.savePatternToMidi(MidiFileManager.java:53)
at org.jfugue.midi.MidiFileManager.savePatternToMidi(MidiFileManager.java:58)
at com.avister.midiGeneration.GenerateMidiActivity.dubSave(GenerateMidiActivity.kt:52)
at com.avister.ml.models.MusicGeneratorAndroidTest$dubSaveTest$1.perform(MusicGeneratorAndroidTest.kt:141)
at com.avister.ml.models.MusicGeneratorAndroidTest$dubSaveTest$1.perform(MusicGeneratorAndroidTest.kt:18)
at androidx.test.core.app.ActivityScenario.lambda$onActivity$2$ActivityScenario(ActivityScenario.java:660)
at androidx.test.core.app.ActivityScenario$$ExternalSyntheticLambda2.run(Unknown Source:4)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.app.Instrumentation$SyncRunnable.run(Instrumentation.java:2223)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.ClassNotFoundException: Didn't find class "jp.kshoji.javax.sound.midi.MidiSystem" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/system/framework/android.test.mock.jar", zip file "/system/framework/android.test.base.jar", zip file "/data/app/~~lil1u2Nb8-ocLGw0F8dAbw==/com.avister.test-F5TBrSomZjMeER7Y26_viQ==/base.apk", zip file "/data/app/~~h9pnhGV0TWqabygf7I8F7Q==/com.avister-zQJ2i_8pkzzeqXPzP3hGLg==/base.apk"],nativeLibraryDirectories=[/data/app/~~lil1u2Nb8-ocLGw0F8dAbw==/com.avister.test-F5TBrSomZjMeER7Y26_viQ==/lib/x86, /data/app/~~h9pnhGV0TWqabygf7I8F7Q==/com.avister-zQJ2i_8pkzzeqXPzP3hGLg==/lib/x86, /data/app/~~lil1u2Nb8-ocLGw0F8dAbw==/com.avister.test-F5TBrSomZjMeER7Y26_viQ==/base.apk!/lib/x86, /data/app/~~h9pnhGV0TWqabygf7I8F7Q==/com.avister-zQJ2i_8pkzzeqXPzP3hGLg==/base.apk!/lib/x86, /system/lib, /system_ext/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 22 more
When trying to perform this test:
internal class MusicGeneratorAndroidTest {
@get:Rule
val activityTestRule = ActivityScenarioRule(GenerateMidiActivity::class.java)
@Test
fun exampleSaveTest() {
activityTestRule.scenario.onActivity {
it.exampleSave()
}
}
}
class GenerateMidiActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_generate_midi)
}
fun exampleSave() {
val cw = ContextWrapper(applicationContext)
val directory = cw.getExternalFilesDir(Environment.DIRECTORY_MUSIC)
val pattern: Pattern = Pattern("C4")
val file = File(directory, "test.midi")
MidiFileManager.savePatternToMidi(pattern, file)
}
}
What may be the cause and how to fix this?
Thank you for the implementation of the JFugue for Android; however, I have an issue that the application doesn't produce sounds though I followed the instructions.
How can I fix this issue?
Thanks in advance.
This library appears to be very useful.
But I'm experiencing issues with such simple example as following
Player player = new Player();
player.play("E5s A5s C6s B5s E5s B5s D6s C6i E6i G#5i E6i | A5s E5s A5s C6s B5s E5s B5s D6s C6i A5i Ri");
I suppose the library should work with this, but it crashes with
java.lang.NullPointerException
jp.kshoji.javax.sound.midi.MetaMessage.setMessage(MetaMessage.java:83)
org.jfugue.midi.MidiEventManager.finishSequence(MidiEventManager.java:156)
org.jfugue.midi.MidiParserListener.afterParsingFinished(MidiParserListener.java:58)
org.jfugue.parser.Parser.fireAfterParsingFinished(Parser.java:61)
org.staccato.StaccatoParser.parse(StaccatoParser.java:130)
org.jfugue.player.Player.getSequence(Player.java:65)
at org.jfugue.player.Player.play(Player.java:82)
@kshoji is that possible to fix?
Hi, good afternoons/night. I am starting in this library for my project and i have a question...
The player make music and hear the music in the phone?
I downloaded and configured my Android Studio project with all repositories in the build.gradle. I have a method that execute this when press a floating action button. And don't throws any exception
It´s just that?
Player player = new Player();
player.play("C D E F G A B");
I want reproduce the music that the player contains when i press the button :D
Regards
Add the sample app that executes the official site's examples.
http://www.jfugue.org/examples.html
Seems that midi files that I generate from your lib are invalid. Should this work?
(I've tried both your JFugue 4 and JFugue5 implementations).
Version 5
Pattern pattern = new Pattern("C D E F G A B");
try {
MidiFileManager.savePatternToMidi(pattern, file);
} catch (IOException e) {
e.printStackTrace();
}
results in an exception
Caused by: java.lang.NullPointerException: Attempt to get length of null array at jp.kshoji.javax.sound.midi.MetaMessage.setMessage(MetaMessage.java:64)
Version 4
Player player = new Player();
Pattern pattern = new Pattern("C D E F G A B");
try {
player.saveMidi(pattern, file);
} catch (IOException e) {
e.printStackTrace();
}
creates unreadable midi files.
There appears to be a bug in the chord parsing process (latest build, but I haven't used it before so I don't know if it was there before) which creates notes for chords sequentially. The track beat time appears to be OK, but the note off messages are written before the note on of subsequent notes in the chord. This means that when the StandardMidiFileWriter writeTrack method tries to evaluate the variableLengthIntLength, the value it is passed is negative, and it loops forever.
As a temporary fix for my build, I have amended the MidiFileManager save method to sort the events in the tracks using the Track.TrackUtils.sortEvents that is already there, which also consequently rebuilds the EOT markers.
This appears to work OK for now.
I know you're going to tell me there is a flag somewhere, but I couldn't find anything.
Hope it helps.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.