Search code examples
r3dwavrgl

Looking to save a 3D spectrograph generated by SeeWave as .STL or similar in R


I'm fairly new to R and was experimenting with the SeeWave package to generate different plots from audio files. I found the 3D spectrograph especially interesting and, since I have access to a 3D printer in lab, thought it would be neat to print some of them.

My problem isn't with generating the plots, that goes quite smoothly, but with saving them in some kind of useful format. I've seen some references to people creating interactive WebGL, but I'm looking to generate some sort of .stl or .obj file that can be cleaned up and printed.

Code looks something like this:

> library(seewave)
> library(tuneR)
> sound <- readWave("/...path.../bird_call.wav")
> spectro3D(sound, wl=1000, ovlp=85, zp=6, maga=8, palette=spectro.colors)

Which generates a nice image - see below.

But I'm lost as to how I can save this in a useful format. Is there some incredibly obvious answer I've somehow missed? Some way to send the output to WriteOBJ from the RGL package? Any help is much appreciated.

enter image description here


Solution

  • The spectro3D() function uses rgl to draw the image, so you can just use rgl::writeOBJ("file.obj").