Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Using Play command and polynomial tia sal2

  • To: mathgroup at smc.vnet.net
  • Subject: [mg97020] Re: Using Play command and polynomial tia sal2
  • From: David Bailey <dave at removedbailey.co.uk>
  • Date: Mon, 2 Mar 2009 05:22:35 -0500 (EST)
  • References: <godm5p$48c$1@smc.vnet.net>

ratulloch at gmail.com wrote:
> Greetings All
> 
> I know the play command uses sin, cos, etc.  But I would like to use
> the Play command to listen to a polynomial.  Example below of
> polynomial
> 
> Plot[Piecewise[{{4*x^2 - 4*x, 0 <= x <= 1}, {-2*x^2 + 8*x - 6
>     , 1 = x < 3}}], {x, 0, 3}]
> 
> I replace the Plot command with Play
> Play[Piecewise[{{4*x^2 - 4*x, 0 <= x <= 1}, {-2*x^2 + 8*x - 6
>     , 1 = x < 3}}], {x, 0, 3}]
> 
> but mathematica 6 just comes back with errors and
> just says running..
> 
> I think it's syntax but I haven't found an example of using the Play
> command and Piecewise.  Should I be doing this another way?
> 
> tia sal2
> 
You had used = instead of == in one of the tests inside Piecewise. 
Curiously, this did not cause an error using Plot. Here is a corrected 
version:

Play[Piecewise[{{4*x^2 - 4*x, 0 <= x <= 1}, {-2*x^2 + 8*x - 6,
     1 == x < 3}}], {x, 0, 3}]

Note that = means assignment, and therefore 1=x doesn't make sense - 
which is what the message was trying to tell you - whereas == is a 
comparison.

However, I am not sure I would pay to attend a concert in which the 
result was playing :)

I think the result would sound more interesting if instead of playing 
f[x], you played Sin[2 Pi f[x] x] with f scaled into the range of (say) 
200-1000. The pitch of the resultant sound would represent the value of f.

David Bailey
http://www.dbaileyconsultancy.co.uk


  • Prev by Date: Re: How to Export the "Manipulate"
  • Next by Date: Re: Delayed function does not behave as original input
  • Previous by thread: Using Play command and polynomial tia sal2
  • Next by thread: Re: Using Play command and polynomial tia sal2