[Gambas-user] accessing "embedded" project files from Shell command
Kevin Fishburne
kevinfishburne at ...1887...
Fri Aug 29 03:11:01 CEST 2014
On 08/28/2014 04:14 PM, Tobias Boege wrote:
> On Thu, 28 Aug 2014, Kevin Fishburne wrote:
>> When you store data files in the project directory and compile the
>> program those files are contained within the resulting .gambas
>> executable. From within the program they can be accessed as though they
>> were in the current directory. Is it possible to access (read only)
>> those files using a command executed by Shell? For example:
>>
>> Shell "cat ./FileInProject"
>>
>> I'm making a very simple SoundFont previewer that calls fluidsynth with
>> the passed SoundFont and a MIDI file embedded in the project/executable.
>>
>> I could load the embedded file then write it to the user's /tmp
>> directory and pass that to fluidsynth, but won't if I don't have to.
>>
> No, the file is compiled into the .gambas archive. When your Gambas code
> executes, the interpreter takes care of those relative paths and maps
> them to the correct places in the (mmap'd?) archive file. An external
> shell can't do that.
>
> If there is some data you normally need during execution, it might be
> better to provide an installation packages which puts these files to
> /usr/share.
>
> But otherwise you can "unpack" the archive once your program starts up
> by recursively copying the "." directory (or any subdirectory of that)
> from inside the Gambas process. We had a thread around here yesterday
> or so which shows how to copy directories recursively. Then refer to the
> files using the temporary location you unpacked them to.
>
> Regards,
> Tobi
>
> PS: Or what Benoit said... BTW: is the .gambas file in a Gambas-specific
> archive format?
>
Thanks Benoît and Tobias. This made it simple enough:
Try Copy "Preview.mid" To "/tmp/Preview.mid"
' Set command string.
Command = "fluidsynth -apulseaudio -i -n \"" & Application.Args[1]
& "\" /tmp/Preview.mid"
' Play sample MIDI file using passed SoundFont.
Shell Command Wait
I attached the insanely simple program in the event anyone would find it
useful. Just associate .sf2 files with the GAMBAS executable and you can
double-click a SoundFont in your file manager to hear a preview. It uses
PulseAudio and fluidsynth, so adjust as necessary. The general idea is
to make the organization of SoundFonts easier by allowing the use of
your distro's file manager.
--
Kevin Fishburne
Eight Virtues
www: http://sales.eightvirtues.com
e-mail: sales at ...1887...
phone: (770) 853-6271
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SF2Preview.tar.gz
Type: application/gzip
Size: 5690 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20140828/014bc5dc/attachment.gz>
More information about the User
mailing list