MathGroup Archive 2002

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

Search the Archive

Mathematica, sounds and placing graphics

  • To: mathgroup at smc.vnet.net
  • Subject: [mg32835] Mathematica, sounds and placing graphics
  • From: "Enrico Luciano" <e.luciano at NOSPAMMMwirecom.it>
  • Date: Thu, 14 Feb 2002 01:44:20 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Dear Sirs,
 I'm a novice using Mathematica and I've a problem I an't solve...

I want to play a sound, but to suppress the graphic or (better) place the
graphic somewhere in my notebook...

I tried to do this with Simple text and it worked fine:

As an example;


CellPrint[
    Cell[TextData["1"], "Output", Evaluatable -> False,
      CellTags -> {"suono1"}]];
CellPrint[
    Cell[TextData["2"], "Output", Evaluatable -> False,
      CellTags -> {"suono2"}]];
CellPrint[
    Cell[TextData["3"], "Output", Evaluatable -> False,
      CellTags -> {"suono3"}]];
CellPrint[
    Cell[TextData["4"], "Output", Evaluatable -> False,
      CellTags -> {"suono4"}]];

and

mymodule:=Module[
  {x, y, nb = ButtonNotebook[]},
  NotebookFind[nb, "suono2", All, CellTags];
  SelectionMove[nb, All, Cell];
  NotebookWrite[nb,
    Cell[TextData["Here!"], "Output", Evaluatable -> False,
      CellTags -> {"suono2"}]
    ];
  ]


then I've a button:

CellPrint[
    Cell[BoxData[
        ButtonBox["Substitute", Active -> True, ButtonEvaluator ->
Automatic,
          ButtonFunction :> mymodule]]]];


Everything works fine here: I get four tagged cells, and when I click on my
button the "2" become "Here!"...

Now I have a sound generated as follows:

suond = Miscellaneous`Audio`Waveform[Miscellaneous`Audio`Triangle, 400, 0.5

If I do Show[sound] it plays fine...

But when I try to put it (the graphic, obviously) in the second tagged cell
it wont work. I modify the module as follows:


mymodule:=Module[
  {x, y, nb = ButtonNotebook[]},
  NotebookFind[nb, "suono2", All, CellTags];
  SelectionMove[nb, All, Cell];
  NotebookWrite[nb,
    Cell[GraphicsData[Show[suond]], "Graphics", Evaluatable -> False,
      CellTags -> {"suono2"}]
    ];
  ]


but nothing goes in the cell, the graphics goes after my button...
In my opinion the problem is the use of the Show Function so I researche how
to "pass" grahics and sounds... But I found nothing about sounds...


I also tried modifying something like:


gr = Plot3D[Sin[x y], {x, 0, Pi}, {y, 0, Pi}, DisplayFunction -> Identity];
nb = NotebookPut[
      Notebook[{Cell[GraphicsData["PostScript", DisplayString[gr]],
            "Graphics", ShowCellBracket -> False,
            ImageMargins -> {{0, 0}, {0, 0}}]},
        WindowSize -> {FitAll, FitAll}, WindowElements -> {}]];


to open a new notebook, but I got nothing useful.
I've read somewhere on the Mathematica book that sound can be encapsulated
embedded with graphics as Postscript and played on systems with audio
capabilities...


Is there anyone who can help me?

I need this for a college exam.. the rest of the noteboo is fine, I've only
problems with this.

Best regards...

Enrico







  • Prev by Date: RE: ReadList of Data containing "nan"
  • Next by Date: Re: RE: Re: Newbie Question
  • Previous by thread: Re: Linebreaks and style when saving as TeX
  • Next by thread: Re: Mathematica, sounds and placing graphics