[R-SIG-Mac] sound::setWavPlayer()
Prof Brian Ripley
ripley at stats.ox.ac.uk
Thu Aug 28 10:17:10 CEST 2008
On Thu, 28 Aug 2008, Hans-Jörg Bibiko wrote:
>
> On 27.08.2008, at 17:21, Hans-Jörg Bibiko wrote:
>
>> On 27.08.2008, at 17:06, Simon Urbanek wrote:
>>
>>> To be precise to play an audio file all you do is
>>> [[[NSSound initWithContentsOfFile:fileName byReference:YES] autorelease]
>>> play];
>>> Thats' all :)
>>
>> Ah, you mean that the function play(A_SOUND_FILE) should be part of R's
>> core code which implements it for a given platform.
>> This of course would be the best way.
No, because that just throws the problem onto R-core, including long-term
maintenance, for what is a real minority interest. It should be a
user-maintained package.
> I thought about it a bit. For Mac it would be trivial, but for Windows and
> Linux I do not know. They have to support many sound card drivers. For Linux
> you have different window servers, and distributions.
> The next point once you have such a built-in function like playSoundFile(f)
> how to control it, i.e how to stop it for instance; esp. for the case that
> you're playing more than one sound file at a time (which works a Mac with
> play very well).
>
> To use the approach to open a sound file by the default application is in
> some sense better. On Mac it's easy, just type 'open FILE', for Windows this
> works only in some cases. One could use 'start FILE' but 'start' is not an
> executable it's a DOS command thus one could write a BAT file open.BAT à la
> 'start %1'.
Please do your homework: Windows R has long provided shell.exec() and as
from R 2.8.0 will have open.exe (for use in shell scripts such as
Rd2dvi.sh).
So all you need to do on Windows R is shell.exec("filename"), even easier
than Simon's suggestion.
> The tricky point is Linux in that respect I believe.
What about all the other platforms R runs on -- FreeBSD, Solaris, AIX,
IRIX, ...?
> I do not know any command which can do this. The Linux shell command
> 'play' is not part of any distribution. This leads to a next problem. If
> there would be a general solution to play a sound file using the default
> app OK but if the user can set up the player to 'mplayer32.exe', or
> 'play' etc. how to distinguish between a shell command, which could run
> in the background (how to control it?), and a app based program like
> 'Windows Media Player' or 'QuickTime' etc.?
>
>
> The only idea I have for now is to use a scripting language to write a
> primitive audio player, and the only language which is installed by default
> on all these platforms is Java. It shouldn't be that problem to write such a
> JFrame jar.
But having a working Java is a problem.
> Cheers,
>
> --Hans
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-SIG-Mac
mailing list