From: dh on


Hi Ben,

the error message is not too clear. The problem is that Play has the

attribute HoldAll. Therefore Play gets the unevaluated expression and

not a list of functions. You need "Evaluate";



Play[Evaluate[Sin[# 2 Pi t] & /@ notes], {t, 0, .5}]



Daniel



BenT wrote:

> I'm using v7. Please try this code:

>

> ClearAll["Global`*"]

>

> notes=Table[N[(440/64)*2^((n+3)/12)],{n,60,72,1}];

>

> Play[Sin[# 2 Pi t]&/@notes ,{t,0,.5}]

>

> Sound::ssnm: A good PlayRange could not be found since most of the

> samples are not evaluating to machine-size real numbers. >>

>

> I cannot understand why this error message is produced. Can anyone

> help? The values for the "notes" are certainly machine-sized! What's

> causing the Sin[# # Pi t] expression to NOT produce valid resuls?

>

> --- Benjamin Tubb

>



From: BenT on
Thanks to all that replied. Here is the finale "solution" to what I
wanted.

ClearAll["Global`*"]

notes = Table[N[ (440 / 64) * 2^((n + 3) / 12)], {n, 60, 72, 1}];

Sound[
Play[
Evaluate[Sin[# 2 Pi t]] & /@ notes, {t,0,.5}]
]

I've since been able to do something much more practical and
convenient.

(* 7-Note Tuning Systems *)

Manipulate[
scale = {0, s2, s3, s4, s5, s6, s7, 1200};
freq = cents[#] & /@ scale;
Sound[
Play[
Evaluate[Sin[# 2 Pi t]], {t, 0, .5}] & /@ freq],
{{bf, 440, "Base Frequency"}, 27.5, 6017, Appearance -> "Labeled"},
{{s2, 200}, 2, s3 - 2, Appearance -> "Labeled"},
{{s3, 400}, s2 + 2, s4 - 2, Appearance -> "Labeled"},
{{s4, 500}, s3 + 2, s5 - 2, Appearance -> "Labeled"},
{{s5, 700}, s4 + 2, s6 - 2, Appearance -> "Labeled"},
{{s6, 900}, s5 + 2, s7 - 2, Appearance -> "Labeled"},
{{s7, 1100}, s6 + 2, 1198, Appearance -> "Labeled"},
Initialization :>
{SetOptions[Play, SampleDepth -> 16, SampleRate -> 44100],
SetOptions[Sound, SoundVolume -> .5],
cents[x_] := N[bf 2^(x/1200)]
}]

--- Benjamin Tubb



From: DrMajorBob on
Your final solution yields no sound, throws an error message, AND hangs
the kernel at my machine:

notes = Table[N[(440/64)*2^((n + 3)/12)], {n, 60, 72, 1}];
Sound[Play[Evaluate[Sin[# 2 Pi t]] & /@ notes, {t, 0, .5}]]

$Version

"7.0 for Mac OS X x86 (64-bit) (February 19, 2009)"

Your Manipulate DOES work, on the other hand. (As far as I can tell, since
I don't know what it's supposed to sound like.)

Bobby

On Fri, 11 Dec 2009 03:18:02 -0600, BenT <brtubb(a)pdmusic.org> wrote:

> Thanks to all that replied. Here is the finale "solution" to what I
> wanted.
>
> ClearAll["Global`*"]
>
> notes = Table[N[ (440 / 64) * 2^((n + 3) / 12)], {n, 60, 72, 1}];
>
> Sound[
> Play[
> Evaluate[Sin[# 2 Pi t]] & /@ notes, {t,0,.5}]
> ]
>
> I've since been able to do something much more practical and
> convenient.
>
> (* 7-Note Tuning Systems *)
>
> Manipulate[
> scale = {0, s2, s3, s4, s5, s6, s7, 1200};
> freq = cents[#] & /@ scale;
> Sound[
> Play[
> Evaluate[Sin[# 2 Pi t]], {t, 0, .5}] & /@ freq],
> {{bf, 440, "Base Frequency"}, 27.5, 6017, Appearance -> "Labeled"},
> {{s2, 200}, 2, s3 - 2, Appearance -> "Labeled"},
> {{s3, 400}, s2 + 2, s4 - 2, Appearance -> "Labeled"},
> {{s4, 500}, s3 + 2, s5 - 2, Appearance -> "Labeled"},
> {{s5, 700}, s4 + 2, s6 - 2, Appearance -> "Labeled"},
> {{s6, 900}, s5 + 2, s7 - 2, Appearance -> "Labeled"},
> {{s7, 1100}, s6 + 2, 1198, Appearance -> "Labeled"},
> Initialization :>
> {SetOptions[Play, SampleDepth -> 16, SampleRate -> 44100],
> SetOptions[Sound, SoundVolume -> .5],
> cents[x_] := N[bf 2^(x/1200)]
> }]
>
> --- Benjamin Tubb
>
>
>


--
DrMajorBob(a)yahoo.com

From: BenT on
Sorry, I "misplaced" the closing "Evaluate" function bracket (which is
apparently critical <g>! The code should be:

(* start *)
ClearAll["Global`*"]

notes = Table[N[ (440 / 64) * 2^((n + 3) / 12)], {n, 60, 72, 1}];

Sound[
Play[
Evaluate[Sin[# 2 Pi t] & /@ notes], {t,0,.5}]
]
(* end *)

I also corrected an "initialization" error with "bf" in the other code
shown:

(* start *)
(* 7-Note Tuning Systems *)

Manipulate[
scale = {0, s2, s3, s4, s5, s6, s7, 1200};
cents[x_] := N[bf 2^(x/1200)];
freq = cents[#] & /@ scale;
Sound[
Play[
Evaluate[Sin[# 2 Pi t]], {t, 0, .5}] & /@ freq],
{{bf, 440, "Base Frequency"}, 27.5, 6017, Appearance -> "Labeled"},
{{s2, 200}, 2, s3 - 2, Appearance -> "Labeled"},
{{s3, 400}, s2 + 2, s4 - 2, Appearance -> "Labeled"},
{{s4, 500}, s3 + 2, s5 - 2, Appearance -> "Labeled"},
{{s5, 700}, s4 + 2, s6 - 2, Appearance -> "Labeled"},
{{s6, 900}, s5 + 2, s7 - 2, Appearance -> "Labeled"},
{{s7, 1100}, s6 + 2, 1198, Appearance -> "Labeled"},
Initialization :>
{SetOptions[Play, SampleDepth -> 16, SampleRate -> 44100],
SetOptions[Sound, SoundVolume -> .5]
}]
(* end *)

--- Benjamin Tubb