【问题标题】:writing wav-file in shiny app with seewave and tuneR使用 seewave 和 tuneR 在闪亮的应用程序中编写 wav 文件
【发布时间】:2019-06-29 23:17:12
【问题描述】:

我有一个带有许多 tabPanel 的闪亮应用。 在其中一个面板中,我想将 seewave 和 tuneR 中生成的时间信号写入 www 子目录。 如果我在 R-promt 上运行命令,一切正常,但我无法让它在我的 server.R 中运行。 我试过观察,但是输入$变量没有更新:

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)
})

【问题讨论】:

  • 嗨,这个问题有什么进展吗?我现在也面临同样的情况。运行服务器时没有执行代码......

标签: r shiny


【解决方案1】:

我设法以某种方式保存了文件。我定义了生成声音并预先加载它的函数。然后在服务器函数中我这样称呼它:

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))

  })

}

然后在 UI 中实现它,请遵循 this 和 this

【讨论】:

    猜你喜欢
    • 2016-05-27
    • 2013-07-08
    • 2016-05-23
    • 2014-11-10
    • 2016-02-09
    • 2017-04-12
    • 2018-03-02
    • 2016-12-29
    • 1970-01-01
    相关资源
    最近更新 更多