IO port logic.

John PaulJohn Paul Junior MemberPosts: 143
I have a site where i have 7 mics connected on the IO port of a NI controller. Now when ever a person speaks, the mic which the person speaks thro turns the respective IO channel in the IO port and there is camera preset associated with each mic.

But when there are two or more speakers at the same time, the client wants the camera to go to a default preset which shows the full room. But since the two or more speakers will speak maybe for a sec or two, it goes immediately to the default preset and comes back to the speaker who spoke last. I wanted to know if there is any way where if it detects two or more speakers speaking, till there is a single speaker, it will stick to the default preset. I tried combining channel events for this purpose but to no avail.

Comments

  • Spire_JeffSpire_Jeff Formerly Caffeinated Programmer Posts: 1,917
    You might consider using a variable in conjunction with a timeline or waits to determine if 2 people speak within xTime of each other and then lock in the room view for a set amount of time. At the end of the lockout time, it decides if more than one person is still speaking and either renew the lock out, or switch to single view. Also, you might think about switching to room view if nobody speaks for a set amount of time.

    Now to answer your question... I don't think there is a built-in function that will help you do this. You will need to write the code with the logic desired to accomplish this. If this seems like something you aren't comfortable doing yet, I am sure there are a couple of independent programmers on the forums that could write you some code for a fee to get you going.

    Jeff
  • John PaulJohn Paul Junior Member Posts: 143
    Thanks Jeff

    I just needed a logic for this, i been programming for 5 years and its always good to ve different view points for a problem
  • ericmedleyericmedley Senior Member - 3709 Posts Posts: 4,157
    Here's a simple idea.

    create a simple for loop that checks each I/O port

    keep a running tally of 'on' ports. If it exceeds 1 turn a variable flag on. If flag is on, send the camera to the preset
  • HedbergHedberg Junior Member Posts: 671
    So, what you want to avoid is having the camera quickly/repeatedly switching between the "default" preset and the presets selected when there is only only one active mic at a time.

    here's one way you might do it:
    //When an IO senses on, it sends a push
    button_event[dvIO,1]
    {
      push:
      {
          nIOSum = fnIO_Sum()//function which gives the sum of the io statuses
          if(nIOSum = 1) //if this is the only active mic
          {
             fnCamPreset(1)
           }
           else//more than one mic is active
          {
             fnCamPreset(0)//the default preset
           }
      }
      release:
      {
         fnCamPreset(0)//the default preset
       }
    }
    

    What I expect this would do is to switch to a camera preset if only one mic is active and switch to the default preset if more than one mic is active or when the single active mic goes inactive. If this last creates a problem (if you don't want to got to the default preset quickly when a mic is released) you could use a named wait to delay the move to default preset on the release and kill the wait if another preset went active during the wait time.

    Of course, you could combine all the IO button presses into one event and use a button array, or any other code paradigms you like. Just trying to demonstrate the logic.
  • felixmoldovanfelixmoldovan Junior Member Posts: 197
    Spire_Jeff wrote: »
    Now to answer your question... I don't think there is a built-in function that will help you do this.

    How about
    SET_PULSE_TIME nDefaultPresetHoldTime
    MIN_TO [vdvDefaultPreset, 1]
    

    where vdvDefaultPreset is a purpose defined virtual device for holding a flag for the requested lag time.
    This gets UP every time there is more than one mic active, or none, and it stays UP for at least nDefaultPresetHoldTime. When it goes down, it is safe to go to individual framing.

    To best of my understanding, this was the question asked...
  • DHawthorneDHawthorne Junior Member Posts: 4,584
    If you use SET_PULSE_TIME, remember it's global, and applies to all PULSE commands, including IR and relays. Be sure to put it back if you are using PULSE anywhere else.
  • felixmoldovanfelixmoldovan Junior Member Posts: 197
    John Paul is an experienced programmer. I think the topic was more subject to dissertation as far as "how would you approach this"? I am sure he will take all the precautions related to SET_PULSE_TIME ;)
  • DHawthorneDHawthorne Junior Member Posts: 4,584
    John Paul is an experienced programmer. I think the topic was more subject to dissertation as far as "how would you approach this"? I am sure he will take all the precautions related to SET_PULSE_TIME ;)

    Be that as it may, you'd be surprised how many experienced programmers aren't aware of things some of us take for granted, and I include myself in that statement. Just throwing it out in case he didn't know.
  • viningvining X Member Posts: 4,348
    DHawthorne wrote: »
    Be that as it may, you'd be surprised how many experienced programmers aren't aware of things some of us take for granted, and I include myself in that statement. Just throwing it out in case he didn't know.
    Also as we gain more experience it means we're also getting older and as we get older we forget more so some things can never be said too much or too often.
  • John PaulJohn Paul Junior Member Posts: 143
    Thanks guys
    DHawthorne wrote: »
    Be that as it may, you'd be surprised how many experienced programmers aren't aware of things some of us take for granted, and I include myself in that statement. Just throwing it out in case he didn't know.

    Dave,u are right. I do end up forgetting the obvious sometimes.

    I will take all ur views and check it up on my next site visit. Thanks guys for your views
Sign In or Register to comment.