Menu

Microphone Input

Help
frggr
2011-06-10
2012-09-22
  • frggr

    frggr - 2011-06-10

    I need to have the microphone constantly recording while at the same time I
    need to be able to get information in set intervals.

    My attempt was to create a FrontEndSplitter with the microphone as the input.
    I would then add a custom class that implements dataListener and dataProcessor
    which would grab the data for a set amount of time. This listener would then
    be the input into my front-end pipeline.

    The problem I run into is that the dataListener never buffers any Data
    Objects. The reason being that there is no new data available to be processed
    by the listener until after you call stopRecording() on the microphone.

    My question is there anyway to access the Data Objects before you call
    stopRecording()?

     
  • Nickolay V. Shmyrev

    I need to have the microphone constantly recording while at the same time I
    need to be able to get information in set intervals.

    Sorry, I haven't understood even this part. Can you elaborate on that?

     
  • frggr

    frggr - 2011-06-13

    Right now I'm using this snippet of code:

    Microphone inputSource = new Microphone(<Microphone input variables go here>);
    inputSource.initialize();
    
    while(<Running Conditions>) {
        inputSource.startRecording();
        delay(100); //Just delays program execution for 100 ms
        inputSource.stopRecording();
    
        //Lots of other code
    }
    

    My entire program relies on this code and I don't want to rewrite large
    portions of it, but I now need to introduce the ability to record the incoming
    audio. My current method would introduce small amounts of lost data every
    100ms.

    My plan to fix this without rewriting large sections of code was to write a
    class that acts like a pseudo microphone.

    A class the implements dataListener and DataProcessor. It will then listen for
    data coming out of the actual microphone which should be recording until the
    program stops running.

    When startRecording was called on the pseudo Microphone it will tell the
    object to start grabbing data; When stopRecording is called it will
    stopGrabbing data. The rest of my code would be able to run off of this.

    The problem I am having is that the Microphone class doesn't create any data
    the listener can see until after stopRecording is called. (Which I hope to
    never call.) My question is if there is a way around this.

     
  • Nickolay V. Shmyrev

    I still do not understand you and I think you still don't understand how to
    use sphinx4 properly.

    Microphone recording is already running in separate thread, you can do things
    while it's recording. You can retrieve arbitrary number of frames you need and
    then process them in your application. There is no need to stop recording or
    start it between this.

    You can just do

    microphone.startRecording

    while (true) {
       microphone.getData()
       processData()
    }
    
     

Log in to post a comment.