Re: Using "/@" Effectively

• To: mathgroup at smc.vnet.net
• Subject: [mg104324] Re: [mg104292] Using "/@" Effectively
• From: Bob Hanlon <hanlonr at cox.net>
• Date: Tue, 27 Oct 2009 05:01:20 -0500 (EST)
• Reply-to: hanlonr at cox.net

```Change to read:

Sound[melody[#[[1]], #[[2]]] & /@
{{0, 1.}, {5, 0.5}, {7, 0.5}, {12, 1.}},
{0, 3.}, SoundVolume -> .5]

Note that because of constraints on arguments to melody, that 2nd part of argument in list must be Real or use

Sound[melody[#[[1]], N[#[[2]]]] & /@
{{0, 1}, {5, 0.5}, {7, 0.5}, {12, 1}},
{0, 3}, SoundVolume -> .5]

Bob Hanlon

---- BenT <brtubb at pdmusic.org> wrote:

=============
Given:

\$Version
"7.0 for Microsoft Windows (32-bit) (January 30, 2009)"

miditofreq[n_Integer] := (440./64) 2^((n + 3)/12);

and

melody[p_Integer, d_Real] :=
Play[Sin[miditofreq[p] 2 \[Pi] t], {t, 0, d}, SampleRate -> 44100,
SampleDepth -> 16]

I want to be able to use a list of pitch and duration values for a
melody, and use it like the following, but cannot determine the method
to Map them properly, as in this (non-working) attempt:

Sound[melody[#1, #2] & /@ {{0, 1}, {5, 0.5}, {7, 0.5}, {12, 1}}, {0,
3}, SoundVolume -> .5]

Can anyone show me the correct (or even a better) way to do so?

```

• Prev by Date: Re: How to format Superscript and Subscript for a symbol to the same
• Next by Date: old vs new(V7) BarChart3D
• Previous by thread: Re: Using "/@" Effectively
• Next by thread: Re: Using "/@" Effectively