GEN01 on Android
Date | 2017-04-30 14:20 |
From | Andrea Strappa |
Subject | GEN01 on Android |
Hi list, I tested this simple instrument:
instr 2 iamp = .5 icoda = .1 xtratim icoda kenv linsegr 0, .1, iamp, p3-.1, iamp, icoda, 0 asig buzz kenv, 660, 5, 1 outs asig, asig endin by Android Studio Java String:
String event = String.format("i2 0 1"); It plays! But this instrument: instr 3 ;WITH WAV SAMPLE iamp = .5 icoda = .1 xtratim icoda kenv linsegr 0, .1, iamp, p3-.1, iamp, icoda, 0 asig oscili kenv, sr*2/ftlen(2), 2 outs asig, asig endin by Android Studio Java String: String event = String.format("i3 0 1"); with function: f2 0 65536 1 "g4_pianoforte.wav" 0 0 0 Don't play! .csd file and .wav file are in same directory "raw". Although I read in Csound Journal ( Brian Redfern, http://www.csoundjournal.com/issue17/android_csd_player.html ): "I keep it easy and place my impulse files into the same folder as my CSD so I do not have to figure out the path". Why can't I listen the GEN01 sample? In CsoundQt I can listen it with same instrument. Greetings Andrea S.
|
Date | 2017-04-30 14:54 |
From | Steven Yi |
Subject | Re: GEN01 on Android |
Hi Andrea, Could you post the full CSD and error message you get? Or better, a zip of a project posted somewhere to download? steven On Sun, Apr 30, 2017 at 9:20 AM, Andrea Strappa |
Date | 2017-04-30 16:14 |
From | Tarmo Johannes |
Subject | Re: GEN01 on Android |
Hi, I have not written an app on Android for some time but if I remember correct, the csd is copied to temporary file due permissions problem and the sound file is not in the same folder then any more. Can you try to put the sound file to sdcard and set full path in f2 declaration to test if that was the issue? Hope it helps, Tarmo 30.04.2017 16:20 kirjutas kuupäeval "Andrea Strappa" <a_strappa@tin.it>:
|
Date | 2017-04-30 17:55 |
From | Andrea Strappa |
Subject | Re: GEN01 on Android |
I sent the project to Steven. I look forward to his precious ispection, before making other attemps. Thank you Il 30/04/2017 17:14, Tarmo Johannes ha
scritto:
|
Date | 2017-05-01 00:51 |
From | Steven Yi |
Subject | Re: GEN01 on Android |
Hi Andrea, I took a look at the project and I had to spend a little time to remember the design. Tarmo is correct in that the examples typically write a temporary csd file then run. What could be done is that when your program first starts, you could take the files from res/raw (or use assets, which I think was added after we first did the Android Csound version) and write them to external storage (which may or may not be an SD card). After that you could then run Csound using the version from external storage. There's a number of posts about writing to external storage. Something like this: http://stackoverflow.com/questions/4447477/how-to-copy-files-from-assets-folder-to-sdcard might work. I myself haven't tried this; perhaps someone else has and can report here? Also, it might be nice to add an API example for this scenario in the Csound Examples project for Android. Perhaps someone can contribute such an example. steven On Sun, Apr 30, 2017 at 12:55 PM, Andrea Strappa |
Date | 2017-05-01 00:57 |
From | Steven Yi |
Subject | Re: GEN01 on Android |
BTW: It looks like Android's Expansion files is a system they added to address this kind of issue: https://developer.android.com/google/play/expansion-files.html It seems to download and copy files to external storage automatically, which might also get over the problem of duplicating files within the APK and the external storage. On Sun, Apr 30, 2017 at 7:51 PM, Steven Yi |
Date | 2017-05-01 01:00 |
From | Steven Yi |
Subject | Re: GEN01 on Android |
Actually, that seems to be specific to Google Play services, which may not be desirable. To summarize, what I'm understanding is: 1. Package resources with Android project. On start, write to external storage a second copy of files and resources, then run from there. 2. Don't package resources. When program starts, download from external source (maybe hosted on a web server) and unzip to external storage. Run from there. 3. Use expansion files, which also downloads and unpacks to external storage, then run from external storage. If anyone else has ideas, would love to hear them! steven On Sun, Apr 30, 2017 at 7:57 PM, Steven Yi |
Date | 2017-05-01 16:57 |
From | Andrea Strappa |
Subject | Re: GEN01 on Android |
thank you, Steven, for careful explanation. I attempted the first of your three solutions, for now. I used the method: copyFilesToSdCard
from: http://stackoverflow.com/questions/4447477/how-to-copy-files-from-assets-folder-to-sdcard I write this path:
and the .csd and .wav files of 'assets' directory are well copied in the specified path of my phone. I tryed some f2 path: f2 0 65536 1 "sdcard/MyAppCsound_11/voices/f4_pianoforte.wav" and so on. but I can't listen the sample. I tryed also with '\' instead '/'.
I have to write another path? What is the folder of temporary .csd file? Perhaps I have to copy the .wav samples here. And what path I have to write here?
csoundObj.startCsound((createTempFile(getResourceFileAsString(R.raw.test_04)))); I tried with File csdPath = new File(Environment.getExternalStorageDirectory() + "/sdcard/MyAppCsound_11/voices/test_04.csd"); Then: csoundObj.startCsound((createTempFile(getResourceFileAsString(csdPath))));But a message errore appears: Error:(77, 51) error: incompatible types: File cannot be converted to int Error:Execution failed for task ':app:compileDebugJavaWithJavac'. > Compilation failed; see the compiler error output for details.from 'BaseCsoundActivity' class. Andrea
Il 01/05/2017 02:00, Steven Yi ha scritto:
Actually, that seems to be specific to Google Play services, which may not be desirable. To summarize, what I'm understanding is: 1. Package resources with Android project. On start, write to external storage a second copy of files and resources, then run from there. 2. Don't package resources. When program starts, download from external source (maybe hosted on a web server) and unzip to external storage. Run from there. 3. Use expansion files, which also downloads and unpacks to external storage, then run from external storage. If anyone else has ideas, would love to hear them! steven On Sun, Apr 30, 2017 at 7:57 PM, Steven Yi <stevenyi@gmail.com> wrote:BTW: It looks like Android's Expansion files is a system they added to address this kind of issue: https://developer.android.com/google/play/expansion-files.html It seems to download and copy files to external storage automatically, which might also get over the problem of duplicating files within the APK and the external storage. On Sun, Apr 30, 2017 at 7:51 PM, Steven Yi <stevenyi@gmail.com> wrote:Hi Andrea, I took a look at the project and I had to spend a little time to remember the design. Tarmo is correct in that the examples typically write a temporary csd file then run. What could be done is that when your program first starts, you could take the files from res/raw (or use assets, which I think was added after we first did the Android Csound version) and write them to external storage (which may or may not be an SD card). After that you could then run Csound using the version from external storage. There's a number of posts about writing to external storage. Something like this: http://stackoverflow.com/questions/4447477/how-to-copy-files-from-assets-folder-to-sdcard might work. I myself haven't tried this; perhaps someone else has and can report here? Also, it might be nice to add an API example for this scenario in the Csound Examples project for Android. Perhaps someone can contribute such an example. steven On Sun, Apr 30, 2017 at 12:55 PM, Andrea Strappa <a_strappa@tin.it> wrote:I sent the project to Steven. I look forward to his precious ispection, before making other attemps. Thank you Il 30/04/2017 17:14, Tarmo Johannes ha scritto: Hi, I have not written an app on Android for some time but if I remember correct, the csd is copied to temporary file due permissions problem and the sound file is not in the same folder then any more. Can you try to put the sound file to sdcard and set full path in f2 declaration to test if that was the issue? Hope it helps, Tarmo 30.04.2017 16:20 kirjutas kuupäeval "Andrea Strappa" <a_strappa@tin.it>:Hi list, I tested this simple instrument: instr 2 iamp = .5 icoda = .1 xtratim icoda kenv linsegr 0, .1, iamp, p3-.1, iamp, icoda, 0 asig buzz kenv, 660, 5, 1 outs asig, asig endin by Android Studio Java String: String event = String.format("i2 0 1"); It plays! But this instrument: instr 3 ;WITH WAV SAMPLE iamp = .5 icoda = .1 xtratim icoda kenv linsegr 0, .1, iamp, p3-.1, iamp, icoda, 0 asig oscili kenv, sr*2/ftlen(2), 2 outs asig, asig endin by Android Studio Java String: String event = String.format("i3 0 1"); with function: f2 0 65536 1 "g4_pianoforte.wav" 0 0 0 Don't play! .csd file and .wav file are in same directory "raw". Although I read in Csound Journal ( Brian Redfern, http://www.csoundjournal.com/issue17/android_csd_player.html ): "I keep it easy and place my impulse files into the same folder as my CSD so I do not have to figure out the path". Why can't I listen the GEN01 sample? In CsoundQt I can listen it with same instrument. Greetings Andrea S. Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted hereCsound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted hereCsound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here |
Date | 2017-05-01 19:48 |
From | Steven Yi |
Subject | Re: GEN01 on Android |
Hi Andrea, If the files are copied (the CSD and the .wav), then you shouldn't need to change anything with the CSD as Csound will correctly load the .wav file relative to the CSD. For your Android code, you would use something like: File csdPath = new File(Environment.getExternalStorageDirectory() + "/sdcard/MyAppCsound_11/voices/test_04.csd"); Then: csoundObj.startCsound(csdPath); because csdPath is already a File object. You'll just have to make sure the csdPath is the correct path (not sure you need to have "/sdcard" as part of the path is Environment.getExternalStorageDirectory() is returning that). steven On Mon, May 1, 2017 at 11:57 AM, Andrea Strappa |
Date | 2017-05-01 22:05 |
From | Andrea Strappa |
Subject | Re: GEN01 on Android |
Ok! Resolved! I had neglected to changed the parameter in csoundObj.startCsound(); Thank you Steven. Il 01/05/2017 20:48, Steven Yi ha scritto: > Hi Andrea, > > If the files are copied (the CSD and the .wav), then you shouldn't > need to change anything with the CSD as Csound will correctly load the > .wav file relative to the CSD. For your Android code, you would use > something like: > > File csdPath = new File(Environment.getExternalStorageDirectory() + > "/sdcard/MyAppCsound_11/voices/test_04.csd"); > > Then: > > csoundObj.startCsound(csdPath); > > because csdPath is already a File object. You'll just have to make > sure the csdPath is the correct path (not sure you need to have > "/sdcard" as part of the path is > Environment.getExternalStorageDirectory() is returning that). > > steven > > > On Mon, May 1, 2017 at 11:57 AM, Andrea Strappa |
Date | 2017-05-01 22:40 |
From | Steven Yi |
Subject | Re: GEN01 on Android |
Fantastic, very glad that is working now! On Mon, May 1, 2017 at 5:05 PM, Andrea Strappa |
Date | 2017-05-02 09:57 |
From | Andrea Strappa |
Subject | Invite to develop an educational software |
Hi list, I'm a piano teather in a public school, in Italy. I would develop a software as support of scholastic musical education. I imagine an apps collection with a pedagogical progression. There are a lot of apps about intervals, chords, scales. I think that a little boy is most interessed to learn a song that a collection of intervals, scales, chords and is better that he plays an acoustic instrument before using a tablet or a pc, although those instruments are very attractive and useful. Every app could be a support to learn to play a melody with a little xylophone or glockenspiel or recorder, zither, piano, ukulele, guitar, violin and so on (you could start with four-five instruments). At the same time the melody proposed could be an opportunity to improve the musical knowledge. Apps activities: 1) listen seeing instrumental positions, play and rec (by mic or touch) the melody; 2) know the pitches of melody; 3) know the rhythmical unities of melody; 4) know the tonal degrees of melody; 5) learn to intonate the melody (microtuning); 6) compose your melody with pitches and rhythmical unities of melody (drag and drops); 7) know some information about melody; 8) play and rec what do you want. Every activity could be a game, mostly with score, that could be sent to teacher. An apps collection, could be a good support, both for the children learning and for the progress monitoring and for the educational action progress. I began it with Android studio, but I'm not an expert developer. There's someone intersted to this project? All the best Andrea Strappa Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here |