1

I have a shiny app with a number of tabPanels. In one of these panels I want to write a time signal generated in seewave and tuneR to a www subdirectory. If I run the commands on the R-promt, everything works, but I can't get it running in my server.R. I tried observe, but then the input$ variables are not updated:

observeEvent(input$button,{
        cat("Writing wav file")
})
eventReactive(input$button,{
        "Inbutton"
        pi<-4*atan(1)
        s5<-synth(44100,5,input$freq1,input$amp1*2000,"sine",shape=NULL,p=0,
                 am=c(0,0,0),fm=c(0,0,0),harmonics=1,plot=FALSE,output="Wave")
        s6<-synth(44100,5,input$freq2,input$amp2*2000,"sine",shape=NULL,
                  p=input$phase/180*pi,am=c(0,0,0),fm=c(0,0,0),
                  harmonics=1,plot=FALSE,output="Wave")
        s7<-s5+s6  
        str(s7)
        Wobj<-s7
        wav_dir<-"./www"
        wav_file<-file.path(wav_dir,"howling2.wav")
        writeWave(Wobj,filename=wav_file)
        play(s7)
})
pogibas
  • 27,303
  • 19
  • 84
  • 117
pk28831
  • 67
  • 5
  • Hi, any progress with this problem? I'm facing the same at the moment. The code is not being executed while running the server.... – zielinskipp Jun 11 '16 at 22:24

1 Answers1

0

I've managed somehow to save the file. I defined function that generates the sound and load it beforehand. Then in server function I call it like that:

server <- function(input, output){  

  observeEvent(input$button, {
  sound <- sonify(input$name) # this is already a Wave object

  wvname <- paste0("sound", input$button,".wav")
  writeWave(sound, paste0("www/", wvname))

  })

}

Then to implement it in UI follow this and this

Community
  • 1
  • 1
zielinskipp
  • 120
  • 5