Message Boards Message Boards

Avoid crashing the Mathematica kernel while calling to Audio[] ?

GROUPS:

I'm attaching a Notebook. The full contents are:

mySampleRate = 48000;

testSeries = {0, 1, 0}

testAudio = 
 Audio[{testSeries, testSeries}, SampleRate -> mySampleRate]

When I evaluate the Notebook, Mathematica beeps 4 times, and it reports:

An unknown box name (ToBoxes) was sent as the BoxForm for the expression. Check the format rules for the expression.

and when I go to Help -> Why The Beep, Mathematica reports:

The kernel Local has quit (exited) during the course of an evaluation.

Actually, Mathematica's behavior on this Notebook is non-deterministic. Sometimes it beeps 4 times, sometimes it beeps just once, sometimes it gives me different messages when I ask it why the beep.

Attachments:
POSTED BY: Joe Donaldson
Answer
8 months ago

Furthermore, if I merely load the Notebook, do not evaluate it, put the cursor on the word Audio, and press F1, Mathematica beeps 3 times and reports:

Cannot find the kernel with the specified name "".

P.S. On re-testing from a cold-start, it beeps 6 times, not just 3. This is disappointing.

POSTED BY: Joe Donaldson
Answer
8 months ago

When I attempt to Import[] a WAV file, Mathematica just beeps and fails. I'm just asking it to read numbers from a file; I'm not even asking Mathematica to play any audio on my audio-interface.

POSTED BY: Joe Donaldson
Answer
8 months ago

Joe,

Works on my Mac. I suggest you reinstall Mathematica.

POSTED BY: Neil Singer
Answer
8 months ago

Interesting. Thanks for the information.

I'm on Win 10. I re-installed Mathematica on February 18. I'm afraid if a re-install fixed it for me, the fix would only last a few days.

I do think Audio[] worked for me once at the start of yesterday, but I'm unable to get it to work now.

POSTED BY: Joe Donaldson
Answer
8 months ago

I tried reinstalling, but it doesn't help.

  1. Uninstall Mathematica
  2. Restart Win 10
  3. Reinstall Mathematica
  4. Start Mathematica
  5. Type "Audio" and press F1
  6. Mathematica beeps three times and reports "Cannot find the kernel with the specified name "".
POSTED BY: Joe Donaldson
Answer
8 months ago

If instead of running Mathematica (full) I run "Wolfram Mathematica 11 Kernel" and execute the code quoted in my initial post, the code executes without any error. This is not a workaround, but I hope it's a clue.

I'm curious whether any Win 10 users are able to get better results than I'm getting?

POSTED BY: Joe Donaldson
Answer
8 months ago

(accidental double-post deleted)

POSTED BY: Joe Donaldson
Answer
8 months ago

Now I find no error when I use a semicolon to suppress display of the Audio object:

testAudio = Audio[{testSeries, testSeries}, SampleRate -> mySampleRate];

That is likely how I got Audio[] to work yesterday morning, but I hadn't figured that out until now.

If I subsequently attempt to display the Audio object, the error occurs. After the error, if I use Ctrl-Shift-E to view the underlying display-code, I find this. I don't know what to make of it, but maybe someone more expert will find it significant:

Cell[BoxData[
 TagBox[
  DynamicModuleBox[{Audio`AudioObjects`audio$$ = HoldComplete[
    Audio[RawArray["Real32",{0., 1., 0.}], "Real32", Appearance -> Automatic, AudioDevice -> Automatic, 
     SampleRate -> 48000, SoundVolume -> 1]], Audio`AudioObjects`audioID$$, Audio`AudioObjects`buttonState$$ = 
   "Basic", Audio`AudioObjects`newAudio$$}, 
   DynamicBox[ToBoxes[
     Audio`AudioGUI[
     1, Audio`AudioObjects`audioID$$, Audio`AudioObjects`buttonState$$, Audio`AudioObjects`audio$$], 
     StandardForm],
    ImageSizeCache->{42., {6., 11.}},
    TrackedSymbols:>{}],
   Deinitialization:>Clear[Audio`AudioObjects`newAudio$$],
   DynamicModuleValues:>{},
   Initialization:>({Audio`AudioObjects`newAudio$$, Audio`AudioObjects`audioID$$} = 
    Audio`CheckID[Audio`AudioObjects`audio$$, Audio`AudioObjects`audioID$$, Audio`AudioObjects`newAudio$$]),
   UnsavedVariables:>{Audio`AudioObjects`audioID$$, Audio`AudioObjects`newAudio$$}],
  Audio`AudioBox[],
  Editable->False,
  Selectable->False]], "Output",
 CellChangeTimes->{3.6976615171857677`*^9}]

P.S. And now, after restarting Mathematica, it's working fine even if I omit the semicolon. At this time I'm unable to reproduce the error. I don't believe this was a case of user-error, though. Something is not right with Audio[].

P.P.S. And most recently, it Audio[] has become dysfunctional again on my system, and I know of no way to fix it.

POSTED BY: Joe Donaldson
Answer
8 months ago

The issue is in your example. First, you have an error writing a list as ${testSeries, testSeries}$. It Must be $Flattened[]$. Second, from Documentation examples it seems that your $mySampleRate$ must be the length of your list. Third, to produce a sound you must construct a correct Audio data. I suppose that the data you construct must be modified to produce a sound. Concluding, I propose to experiment with the following code:

Manipulate[
 Audio[Table[Mod[i, n], {i, 48000}], "SignedInteger8"],
{{n, 30}, 1, 400, 1}]

Your example is appropriate with the case when $n=2$.

POSTED BY: Valeriu Ungureanu
Answer
8 months ago

Thank you; however,

1) It's no error for testSeries to be non-flattened as I have it. The Audio[] docs explain, "In Audio[data], rows of data are assumed to be channels of the resulting audio." My example pertains to 2-channel (stereo) audio, and that is why I use a list of lists. In any case, flattening the list doesn't stop the kernel from crashing.

2) I don't see how you infer that from the documentation? In the documentation, I have found no such restriction on the SampleRate option. On the contrary, the documentation says, "SampleRate is an option for sound primitives that specifies the number of samples per second to generate for sounds." In countless software-programs and textbooks, "sample rate" is independent of sample-list length, and Mathematica seems to treat sample-rate conventionally.

3) I'm not trying to produce a sound; I'm just trying to write a WAV file to my disk.

4) Your proposed code on my system causes Mathematica to beep several times, and then the kernel crashes.

How do you account for the Mathematica kernel crashing when I merely:

  • start Mathematica;
  • create a new document;
  • type "Audio" and then press F1?

What room for user-error is there in those steps? If you require additional evidence that there is a Mathematica-bug here, I can do a screen-recording and post it to YouTube.

POSTED BY: Joe Donaldson
Answer
8 months ago

Dear Joe, I tried to reproduce your example on my computer with $Win 10$ and that is all I can did following the documentation. I tried to reproduce the Mathematica kernel crashing as you did. On my computer it didn't appear.

POSTED BY: Valeriu Ungureanu
Answer
8 months ago

Thanks for testing it and letting me know.

Audio[] is certainly sick on my system, even after my Mathematica-reinstall this morning. I can't even go to the Audio[] page in the documentation without the kernel crashing, because the documentation itself crashes the kernel. As I reported earlier, the problem is when Mathematica attempts to display an Audio object. There's no problem as long as I suppress the display of the object (by using a semicolon), and there's no problem if I run the "Wolfram Mathematica 11 Kernel" instead of the full front-end.

My system works fine with numerous other audio-programs, and in any case, the problem here isn't with Mathematica playing any sound, the problem is with Mathematica attempting to display an Audio object to the desktop front-end.

POSTED BY: Joe Donaldson
Answer
8 months ago

It looks like that the settings/rights of the Mathematica Front End are somewhat restricted when you run audio file, i.e., the settings/rights in your OS of the Wolfram Mathematica 11 program are not enough to run correctly audio file.

POSTED BY: Valeriu Ungureanu
Answer
8 months ago

I disagree, friend. As I've explained, I'm not trying to play audio. What I am actually trying to do, I've detailed above repeatedly.

Have you considered that there may be a bug in Mathematica? That conclusion seems obvious to me, but it looks like you're unwilling to consider it, no matter what.

POSTED BY: Joe Donaldson
Answer
8 months ago

This thread is leading to anything and everything besides Wolfram acknowledging and fixing this bug, so here is video demonstrating one aspect of the bug:

https://drive.google.com/open?id=0Bzxpw7yVqcD3UTVFS2ZjdmVtd1k

For software to develop in the right direction, sometimes a community needs to say "that's a bug" instead of blaming everything on non-existent user-errors.

POSTED BY: Joe Donaldson
Answer
8 months ago

What further information can I post to assist Wolfram in fixing this bug? Can I leverage off the Trace function or something similar? Are there log files that could be helpful?

POSTED BY: Joe Donaldson
Answer
8 months ago

Thank you.

It occurs to me now that maybe the GPU on my machine is a factor, and that could be why others running Win 10 aren't encountering this.

POSTED BY: Joe Donaldson
Answer
8 months ago

This bug remains in v11.1.0.0.

POSTED BY: Joe Donaldson
Answer
7 months ago

Thanks for that posting. I also have this bug in Windows 7 with version 11.0.1. Audio worked for a couple days then quit. Won't load a .wav file and the kernel crashes. I was wondering if going to 11.1 would fix it, and your post answered that question. I won't be upgrading.

POSTED BY: John Reed
Answer
5 months ago

Here's my tip. It was discussed above your Input syntax was wrong (I did not check if it was)

Here is an example: I plot a Graphics3D[ Cylinder[{0,0,0}] ]. The kernel quits. Usually if I give wrong syntax to a Primitive I just get an un-evaluated return Prim[{...}] and a message (and error box stuff in front end). However the syntax in the example is certainly wrong and if used properly it is displayed properly.

Mathematica 11.0 on Apple Sierra OS crashes at least daily seemingly randomly no matter what is done, in my experience (not a kernel quit, the whole shebang). however i need to upgrade to 11.1.0 which i've delayed on.

POSTED BY: John Hendrickson
Answer
5 months ago

Group Abstract Group Abstract