octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fwd: psylab


From: Rafael Laboissiere
Subject: Re: Fwd: psylab
Date: Sat, 23 Jun 2007 11:51:20 +0200
User-agent: Mutt/1.5.13 (2006-08-11)

* Jordi Gutierrez Hermoso <address@hidden> [2007-06-22 14:18]:

> It recently came up in the debian-science mailing list. I'm not
> personally interested in the field, just in getting the code running.
> I've glanced at it, and most of it seems 2.9-compatible. The struct
> concerns below seem to not be an issue. I think the only problem would
> be sound output.
> 
> I have no idea what kind of coding sound output would require. There
> doesn't seem to be anything of the sort yet in main Octave or in the
> 'forge packages. I don't even know how to code something like that
> portably across architectures.
> 
> I'd just like to hear your ideas on the matter. Can we make Octave sing?

> ---------- Forwarded message ----------
> From: Martin Hansen <address@hidden>
> Date: 22-Jun-2007 11:21
> Subject: Re: Downloaded psylab
>
> [snip]
>
> -  sound output?  psylab uses Matlabs  "standard" function 'sound' for
>   outputting the stimulus.  All different stimulus parts are first just
>   concantenated, after each other, into one single vector called
>   "m_outsig".  And that vector is played via   msound(m_outsig, fs);
>
> [snip]

The following simple minded function would be a valid replacement for
Matlab's sound in Debian under Octave 2.9, with the sox package installed:

function sound (signal, fsamp)
  [status, tmp] = system ("tempfile -s .wav");
  tmp = substr (tmp, 1, length (tmp) - 1);
  wavwrite (tmp, signal, fsamp, 16);
  system (sprintf ("play %s", tmp));
  unlink (tmp);
endfunction

Note that this function needs to be improved with arguments checking (is
"signal" a vector?  Is "fsamp" a positive scalar?).  Besides, since the
number of bits per sample is hard-coded to be 16 in the code above, the user
must be careful in scaling the "signal" vector to the range -32768 and
+32767.

Otherwise, it should be possible to write a .oct file that directly writes
into the audio device (see, e.g. [1]), circumventing the file creation and
file removal as well as the call to "system" in the function above.

[1] http://equalarea.com/paul/alsa-audio.html

-- 
Rafael


reply via email to

[Prev in Thread] Current Thread [Next in Thread]