Пример #1
0
void JamCracker::Play(void)
{
	if (--waitCnt == 0)
	{
		NewNote();
		waitCnt = wait;
	}

	SetChannel(&variables[0]);
	SetChannel(&variables[1]);
	SetChannel(&variables[2]);
	SetChannel(&variables[3]);
}
Пример #2
0
void TrackList::GroupChannels(
   Track &track, size_t groupSize, bool resetChannels )
{
   // If group size is more than two, for now only the first two channels
   // are grouped as stereo, and any others remain mono
   auto list = track.mList.lock();
   if ( groupSize > 0 && list.get() == this  ) {
      auto iter = track.mNode.first;
      auto after = iter;
      auto end = this->ListOfTracks::end();
      auto count = groupSize;
      for ( ; after != end && count; ++after, --count )
         ;
      if ( count == 0 ) {
         auto unlink = [&] ( Track &tr ) {
            if ( tr.GetLinked() ) {
               if ( resetChannels ) {
                  auto link = tr.GetLink();
                  if ( link )
                     link->SetChannel( Track::MonoChannel );
               }
               tr.SetLinked( false );
            }
            if ( resetChannels )
               tr.SetChannel( Track::MonoChannel );
         };

         // Disassociate previous tracks -- at most one
         auto pLeader = this->FindLeader( &track );
         if ( *pLeader && *pLeader != &track )
            unlink( **pLeader );
         
         // First disassociate given and later tracks, then reassociate them
         for ( auto iter2 = iter; iter2 != after; ++iter2 )
             unlink( **iter2 );

         if ( groupSize > 1 ) {
            const auto channel = *iter++;
            channel->SetLinked( true );
            channel->SetChannel( Track::LeftChannel );
            (*iter++)->SetChannel( Track::RightChannel );
            while (iter != after)
               (*iter++)->SetChannel( Track::MonoChannel );
         }
         return;
      }
   }
   // *this does not contain the track or sufficient following channels
   // or group size is zero
   THROW_INCONSISTENCY_EXCEPTION;
}
Пример #3
0
void ChatPanel::Parted(User& who, const wxString& message)
{
	//    assert( m_type == CPT_Channel || m_type == CPT_Server || m_type == CPT_Battle || m_type == CPT_User );
	const bool me_parted = m_channel && &who == &m_channel->GetMe();
	const wxString nick = TowxString(who.GetNick());
	const bool wasactive = m_active_users.erase(nick) > 0;
	if (m_display_joinitem || (wasactive && !who.IsBot())) {
		OutputLine(_T( "** " ) + wxString::Format(_("%s left %s (%s)."), nick.c_str(), GetChatTypeStr().c_str(), message.c_str()), sett().GetChatColorJoinPart());
	}
	if (m_type == CPT_Channel) {
		if (m_channel == 0)
			return;
		if (me_parted) {
			m_channel->panel = nullptr;
			SetChannel(0);
			return;
		}
		if (m_display_joinitem) {
			// change the image of the tab to show new events
			SetIconHighlight(highlight_join_leave);
		}
	} else if (m_type == CPT_Server && me_parted)
		return;
	if (m_show_nick_list && (m_nicklist != nullptr)) {
		m_nicklist->RemoveUser(who);
		UpdateUserCountLabel();
	}
	// Also remove the User from the TextCompletionDatabase
	textcompletiondatabase.Delete_Mapping(TowxString(who.GetNick()));
}
Пример #4
0
CCircuitry* CNeighbour::ConnectTo(LPCTSTR xUserId, DWORD nTimeOut)
{
	CSingleLock pLock( &m_pSection, TRUE );
	
	CCircuitry* pChannel = FindChannel( xUserId );
	if ( pChannel ) return pChannel;
	
	NETRESOURCE ns;
	
	ns.dwScope = RESOURCE_CONNECTED;   
	ns.dwType = RESOURCETYPE_ANY; 
	ns.dwDisplayType = RESOURCEDISPLAYTYPE_GENERIC;
	ns.dwUsage = RESOURCEUSAGE_CONNECTABLE;
	
	ns.lpRemoteName	= Settings.Centric.Remote.GetBuffer(0);
	ns.lpLocalName = NULL;
	ns.lpProvider = NULL;
	
	WNetAddConnection2( &ns, Settings.Centric.Password, Settings.Centric.UserId, 0 );
	
	if ( ! WaitNamedPipe( Settings.Centric.Remote, nTimeOut ) ) return NULL;
	
	pChannel = SetChannel( new CCircuitry( xUserId ) );
	pChannel->ConnectTo( Settings.Centric.Remote, nTimeOut  );
	
	pChannel->SendPacket( new CBindPacket( xUserId, "" ) );
	
	Connect(); return pChannel;
}
Пример #5
0
void ChatPanel::Parted( User& who, const wxString& message )
{
//    assert( m_type == CPT_Channel || m_type == CPT_Server || m_type == CPT_Battle || m_type == CPT_User );
    bool me_parted = m_channel && &who == &m_channel->GetMe();
	if ( m_type == CPT_Channel ) {
		if ( m_channel == 0 ) return;
		if ( me_parted ) {
			m_channel->uidata.panel = 0;
			SetChannel( 0 );
			return;
		}
		if ( sett().GetDisplayJoinLeave( m_channel->GetName() ) ) {
          // change the image of the tab to show new events
          SetIconHighlight( highlight_join_leave );
		  OutputLine( _T( " ** " ) + who.GetNick() + _( " left the " ) + GetChatTypeStr() + _T( "( " ) + message + _T( " )." ), sett().GetChatColorJoinPart(), sett().GetChatFont() );
        }
	} else if ( m_type == CPT_Battle ) {
		if ( sett().GetDisplayJoinLeave( _T( "game/battle" ) ) )  {
		    OutputLine( _T( " ** " ) + who.GetNick() + _( " left the " ) + GetChatTypeStr() + _T( "( " ) + message + _T( " )." ), sett().GetChatColorJoinPart(), sett().GetChatFont() );
        }
	}
	else if ( m_type == CPT_Server && me_parted )
        return;
	if ( m_show_nick_list && ( m_nicklist != 0 ) )
	{
		unsigned int numusers = 0;
		if ( m_type == CPT_Channel ) numusers = GetChannel()->GetNumUsers();
		else if ( m_type == CPT_Server && m_server ) numusers = m_server->GetNumUsers();
		m_usercount_label->SetLabel( wxString::Format( _("%d users"), numusers ) );
		m_nicklist->RemoveUser( who );
	}
	// Also remove the User from the TextCompletionDatabase
	textcompletiondatabase.Delete_Mapping( who.GetNick() );
}
Пример #6
0
int rtl8188eu_oid_rt_pro_set_channel_direct_call_hdl(struct oid_par_priv *poid_par_priv)
{
	u32		Channel;
	int status = NDIS_STATUS_SUCCESS;
	struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);

	RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_set_channel_direct_call_hdl\n"));

	if (poid_par_priv->information_buf_len != sizeof(u32))
		return NDIS_STATUS_INVALID_LENGTH;

	if (poid_par_priv->type_of_oid == QUERY_OID) {
		*((u32 *)poid_par_priv->information_buf) = Adapter->mppriv.channel;
		return NDIS_STATUS_SUCCESS;
	}

	if (poid_par_priv->type_of_oid != SET_OID)
		return NDIS_STATUS_NOT_ACCEPTED;

	Channel = *((u32 *)poid_par_priv->information_buf);
	RT_TRACE(_module_mp_, _drv_notice_, ("rtl8188eu_oid_rt_pro_set_channel_direct_call_hdl: Channel=%d\n", Channel));
	if (Channel > 14)
		return NDIS_STATUS_NOT_ACCEPTED;
	Adapter->mppriv.channel = Channel;

	_irqlevel_changed_(&oldirql, LOWER);
	SetChannel(Adapter);
	_irqlevel_changed_(&oldirql, RAISE);

	return status;
}
Пример #7
0
void SX1276::RxChainCalibration( void )
{
    uint8_t regPaConfigInitVal;
    uint32_t initialFreq;

    // Save context
    regPaConfigInitVal = this->Read( REG_PACONFIG );
    initialFreq = ( double )( ( ( uint32_t )this->Read( REG_FRFMSB ) << 16 ) |
                              ( ( uint32_t )this->Read( REG_FRFMID ) << 8 ) |
                              ( ( uint32_t )this->Read( REG_FRFLSB ) ) ) * ( double )FREQ_STEP;

    // Cut the PA just in case, RFO output, power = -1 dBm
    this->Write( REG_PACONFIG, 0x00 );

    // Launch Rx chain calibration for LF band
    Write ( REG_IMAGECAL, ( Read( REG_IMAGECAL ) & RF_IMAGECAL_IMAGECAL_MASK ) | RF_IMAGECAL_IMAGECAL_START );
    while( ( Read( REG_IMAGECAL ) & RF_IMAGECAL_IMAGECAL_RUNNING ) == RF_IMAGECAL_IMAGECAL_RUNNING )
    {
    }

    // Sets a Frequency in HF band
    settings.Channel=  868000000 ;

    // Launch Rx chain calibration for HF band 
    Write ( REG_IMAGECAL, ( Read( REG_IMAGECAL ) & RF_IMAGECAL_IMAGECAL_MASK ) | RF_IMAGECAL_IMAGECAL_START );
    while( ( Read( REG_IMAGECAL ) & RF_IMAGECAL_IMAGECAL_RUNNING ) == RF_IMAGECAL_IMAGECAL_RUNNING )
    {
    }

    // Restore context
    this->Write( REG_PACONFIG, regPaConfigInitVal );
    SetChannel( initialFreq );
}
Пример #8
0
Normalization::Normalization() :
   mActualChannel(0),
   mpActualParams(0),
   mNFramesForEstim(0),
   mMeanNorm(false),
   mVarNorm(false),
   mScaleToGVar(false)
{
   strcpy(mpFile, "none");
   SetChannel(0);
}
Пример #9
0
BOOL CNeighbour::AcceptCircuitry()
{
	if ( m_hPipe == INVALID_HANDLE_VALUE ) return Connect( Settings.Centric.Local );
	if ( ! HasOverlappedIoCompleted( &m_pOverlapped ) ) return TRUE;
	
	SetChannel( new CCircuitry( m_hPipe ) );
	
	m_hPipe	= INVALID_HANDLE_VALUE;
	
	return TRUE;
}
Пример #10
0
// Author & Date:   Ehsan Azar     29 March 2011
// Purpose: Open and connect to the library
void CSDKSampleDlg::OnBtnConnect()
{
    cbSdkResult res = cbSdkOpen(0);
    if (res != CBSDKRESULT_SUCCESS)
    {
        PrintError(res);
        return;
    }
    cbSdkConnectionType conType;
    cbSdkInstrumentType instType;
    // Return the actual openned connection
    res = cbSdkGetType(0, &conType, &instType);
    if (res != CBSDKRESULT_SUCCESS)
    {
        SetStatusWindow("Unable to determine connection type");
        return;
    }
    cbSdkVersion ver;
    res = cbSdkGetVersion(0, &ver);
    if (res != CBSDKRESULT_SUCCESS)
    {
        SetStatusWindow("Unable to determine nsp version");
        return;
    }

    if (conType < 0 || conType > CBSDKCONNECTION_CLOSED)
        conType = CBSDKCONNECTION_CLOSED;
    if (instType < 0 || instType > CBSDKINSTRUMENT_COUNT)
        instType = CBSDKINSTRUMENT_COUNT;

    char strConnection[CBSDKCONNECTION_CLOSED + 1][8] = {"Default", "Central", "Udp", "Closed"};
    char strInstrument[CBSDKINSTRUMENT_COUNT + 1][13] = {"NSP", "nPlay", "Local NSP", "Remote nPlay", "Unknown"};
    CString strStatus;
    SetStatusWindow(strStatus);
    strStatus.Format("%s real-time interface to %s (%d.%02d.%02d.%02d) successfully initialized\n", strConnection[conType], strInstrument[instType], ver.nspmajor, ver.nspminor, ver.nsprelease, ver.nspbeta);
    SetStatusWindow(strStatus);

    // Slider shows analog threshold
    m_sldThresh.SetRange(-255, 255, TRUE);
    m_sldThresh.SetPageSize(5);

    m_cboChannel.ResetContent();
    char label[cbLEN_STR_LABEL + 1];
    for(UINT16 chan = 1; chan <= cbNUM_ANALOG_CHANS; chan++)
    {
        label[cbLEN_STR_LABEL] = 0;
        res = cbSdkGetChannelLabel(0, chan, NULL, label, NULL, NULL);
        if (res == CBSDKRESULT_SUCCESS)
            m_cboChannel.AddString(label);
    }
    if (m_cboChannel.GetCount() > 0)
        m_cboChannel.SetCurSel(m_channel - 1);
    SetChannel(m_channel);
}
Пример #11
0
void RA_PWMClass::ChannelPWMParabola(byte Channel, byte Start, byte End)
{
	SetChannel(Channel,PWMParabola(
		InternalMemory.StdLightsOnHour_read(),
		InternalMemory.StdLightsOnMinute_read(),
		InternalMemory.StdLightsOffHour_read(),
		InternalMemory.StdLightsOffMinute_read(),
		Start,
		End, 
		ExpansionChannel[Channel] 
	));	
}
void ModuleTouch::Init(int chan) {
	SetChannel(chan);

	m_buttons[0].Setup(21);
	m_buttons[1].Setup(20);
	m_buttons[2].Setup(19);
	m_buttons[3].Setup(18);

	for (int n = 0; n < 4; n++) {
		m_prevStates[n] = m_buttons[n].IsPressed();
	}
}
Пример #13
0
void RA_PWMClass::ChannelPWMSlope(byte Channel, byte Start, byte End, byte Duration)
{
	SetChannel(Channel,PWMSlope(
		InternalMemory.StdLightsOnHour_read(),
		InternalMemory.StdLightsOnMinute_read(),
		InternalMemory.StdLightsOffHour_read(),
		InternalMemory.StdLightsOffMinute_read(),
		Start,
		End, 
		Duration,  
		ExpansionChannel[Channel] 
	));	
}
Пример #14
0
void RA_PWMClass::ChannelPWMParabola(byte Channel, byte Start, byte End, byte MinuteOffset)
{
	int onTime=NumMins(InternalMemory.StdLightsOnHour_read(),InternalMemory.StdLightsOnMinute_read())-MinuteOffset;
	int offTime=NumMins(InternalMemory.StdLightsOffHour_read(),InternalMemory.StdLightsOffMinute_read())+MinuteOffset;
	SetChannel(Channel,PWMParabola(
		onTime/60,
		onTime%60,
		offTime/60,
		offTime%60,
		Start,
		End, 
		ExpansionChannel[Channel] 
	));	
}
Пример #15
0
void cGraphLCDState::ChannelSwitch(const cDevice * Device, int ChannelNumber)
{
//	printf("graphlcd plugin: cGraphLCDState::ChannelSwitch %d %d\n", Device->CardIndex(), ChannelNumber);
	if (GraphLCDSetup.PluginActive)
	{
		if (ChannelNumber > 0 && Device->IsPrimaryDevice() && !EITScanner.UsesDevice(Device))
		{
			if (ChannelNumber == cDevice::CurrentChannel())
			{
				SetChannel(ChannelNumber);
			}
		}
	}
}
Пример #16
0
bool
Instance::Move(short chan_id, const Time &t, const Time &d, bool display)
{
	if (startTime != t) {
		SetStartTime(t, display);
	}
	if (duration != d) {
		SetDuration(d, display);
	}
	if (chan_id >= 0 && chan_id < uberQua->nChannel) {
		Channel	*c = uberQua->channel[chan_id];
		SetChannel(c, display);
	}
	return true;
}
Пример #17
0
LRESULT CCompositeControl::OnClickedChannelup(WORD wNotifyCode, WORD wID, 
                                              HWND hWndCtl, BOOL& bHandled)
{
    HRESULT hr = S_OK;
    long lPhysicalChannel = 0;
    
    // Get the current physical channel and increment it
    hr =m_pATSCLocator->get_PhysicalChannel(&lPhysicalChannel);
    if (FAILED(hr))
    {
        MessageBox(TEXT("Failed to read physical channel."), TEXT("Error"), MB_OK);
        return hr;
    }
    lPhysicalChannel++;

    hr = SetChannel(lPhysicalChannel);
    return hr;
}
Пример #18
0
cGraphLCDState::cGraphLCDState()
:	first(true),
	tickUsed(false)
{
	channel.number = 0;
	channel.str = "";
	channel.strTmp = "";

	event.presentTime = 0;
	event.presentTitle = "";
	event.presentSubtitle = "";
	event.followingTime = 0;
	event.followingTitle = "";
	event.followingSubtitle = "";

	replay.name = "";
	replay.loopmode = "";
	replay.control = NULL;
	replay.mode = eReplayNormal;
	replay.current = 0;
	replay.currentLast = FRAMESPERSEC;
	replay.total = 0;
	replay.totalLast = 1;

	for (int i = 0; i < MAXDEVICES; i++)
	{
		card[i].recordingCount = 0;
		card[i].recordingName = "";
	}

	osd.currentItem = "";
	osd.title = "";
	for (int i = 0; i < 4; i++)
		osd.colorButton[i] = "";
	osd.message = "";
	osd.textItem = "";
	osd.currentItemIndex = 0;

	volume.value = -1;
	volume.lastChange = 0;

	SetChannel(cDevice::CurrentChannel());
}
Пример #19
0
void SetOption(option_types opt_code, void* value)
{ switch (opt_code)
  { case OPT_CONS_SPEED: { SetConsSpeed(*(uint32_t *) value); break; }
    case OPT_GPS_SPEED:  { SetGPSSpeed (*(uint32_t *) value); break; }
    case OPT_ACFT_ID:    { SetAcftID   (*(uint32_t *) value); break; }
    case OPT_TX_POWER:   { SetTxPower  (*(float    *) value); break; }
    case OPT_XTAL_CORR:  { SetXtalCorr (*(int16_t  *) value); break; }
    case OPT_FREQ_OFS:   { SetFreqOfs  (*(int32_t  *) value); break; }
    case OPT_IWDG:       { SetIWDGDis  (*(uint8_t  *) value); break; }
    case OPT_OPER_MODE:  { SetOperMode (*(uint8_t  *) value); break; }
    case OPT_CHANNEL:    { SetChannel  (*(uint8_t  *) value); break; }
    case OPT_GPSDUMP:    { SetGPSDump  (*(uint8_t  *) value); break; }
    case OPT_MAX_TX_PWR: { SetMaxTxPower  (*(float *) value); break; }
    case OPT_GPS_ALW_ON: { SetGPSAlwON (*(uint8_t  *) value); break; }
    case OPT_GPS_ANT:    { SetGPSAnt   (*(uint8_t  *) value); break; }
    case OPT_JAM_RATIO:  { SetJamRatio (*(uint8_t  *) value); break; }
    case OPT_MIN_BAT_LVL:{ SetMinBatLvl(*(uint16_t *) value); break; }
    case OPT_GPS_WDG_TIME:{SetGPSWdgTime(*(uint16_t *) value); break;}
    default: break; }
}
Пример #20
0
int RxStop()
{
    char buffer[512];
    int ret;
    int i;
    ENTRY;

    error_msg = no_error;

    for(i=0; i <= LAST_RATE_XMIT_RATE; i++)
    {
        sprintf(buffer, "rxstat=%u,0\n",i);
        ret = send_cmd(buffer);
    }
    //send some nonsense to make sure last results are read
    SetChannel(current_channel);

    RETURNI(ret);

    return SUCCESS;
}
Пример #21
0
ChatPanel::ChatPanel(wxWindow* parent, Channel& chan, wxImageList* imaglist)
    : wxPanel(parent, -1)
    , m_show_nick_list(true)
    , m_votePanel(0)
    , m_nicklist(0)
    , m_chat_tabs((SLNotebook*)parent)
    , m_channel(&chan)
    , m_server(0)
    , m_user(0)
    , m_battle(0)
    , m_type(CPT_Channel)
    , m_popup_menu(NULL)
    , m_icon_index(2)
    , m_imagelist(imaglist)
    , m_disable_append(false)
    , m_display_joinitem(false)
    , m_topic_set(false)
    , m_reactOnPromoteEvents(true)
{
	Init(TowxString(chan.GetName()));
	SetChannel(&chan);
}
Пример #22
0
bool SX1276::IsChannelFree( ModemType modem, uint32_t freq, int8_t rssiThresh )
{
    int16_t rssi = 0;
    
    SetModem( modem );

    SetChannel( freq );
    
    SetOpMode( RF_OPMODE_RECEIVER );

    wait_ms( 1 );
    
    rssi = GetRssi( modem );
    
/*************NULL*********/
    
    if( rssi > ( int16_t )rssiThresh )
    {
        return false;
    }
    return true;
}
Пример #23
0
/*!
	errorType STLServerCommandSetChannelXXX::Read()

will have already read the Socket command type and the command id
now need to read the command specific data from the client.
Should only be called from a GSISocket server or derived class

Note that the corresponding ::Write function will be waiting for a
ServerReturnRecord. This function does not return this record as it
doesn't know if the task was completed without error.
The calling code will need to perform the required hardware (or other) tasks
and return the ServerReturnRecord indicating status of the function


Reads
wxInt16 queuedFlag
wxUint16 atTick
wxInt16 channel
*************************************************************************/
errorType STLServerCommandSetChannelXXX::Read(wxSocketBase &sock)
{
//read amplitude
wxInt16 chan;
errorType rv;

	rv=ReadFixedFields(sock);		//reads qflag, at_tick

	sock.Read(&chan,sizeof(chan));
	SetReadFlag(true);
	AppendToReadFromSocketString(chan);
    if(sock.Error())
	{
		MapWxSocketError sockErr(sock.LastError());
		SetLastError(sockErr.GetErrorType());
        return(sockErr.GetErrorType());
	}
	SetChannel(chan);
	FillGSIRecord();
	wxString s;
	s.Printf("Read SetChannel (%i) from client\n",chan);
	AppendText(s);
    return errNone;
}
Пример #24
0
void ModuleRainbow::Init(int chan) {
	SetChannel(chan);
}
Пример #25
0
eOSState cOsdInfoWindow::ProcessKey(eKeys key)
{
    time_t curTime;

    switch (key)
    {
    case k0:
        if (m_Number == 0) {
            m_Group = -1;
            Hide();
            return osUnknown;
        }
    case k1...k9:
        if (m_Number >= 0) {
            m_Number = m_Number * 10 + key - k0;
            if (m_Number > 0) {
                cChannel *channel = Channels.GetByNumber(m_Number);
                m_Channel = channel;
                m_WithInfo = false;
                Show(false, (OsdPipSetup.ShowInfo==0));
                // Lets see if there can be any useful further input:
                int n = channel ? m_Number * 10 : 0;
                while (channel && (channel = Channels.Next(channel)) != NULL) {
                    if (!channel->GroupSep()) {
                        if (n <= channel->Number() && channel->Number() <= n + 9) {
                            n = 0;
                            break;
                        }
                        if (channel->Number() > n)
                            n *= 10;
                    }
                }
                if (n > 0) {
                    // This channel is the only one that fits the input, so let's take it right away:
                    int number = m_Number;
                    m_Number = 0;
                    m_Group = -1;
                    m_WithInfo = true;
                    Channels.SwitchTo(number);
                }
            }
        }
        return osContinue;
    case kLeft | k_Repeat:
    case kLeft:
    case kRight | k_Repeat:
    case kRight:
        m_WithInfo = false;
        if (m_Group < 0) {
            cChannel *channel = Channels.GetByNumber(cDevice::CurrentChannel());
            if (channel)
                m_Group = channel->Index();
        }
        if (m_Group >= 0) {
            int SaveGroup = m_Group;
            if (NORMALKEY(key) == kRight)
                m_Group = Channels.GetNextGroup(m_Group);
            else
                m_Group = Channels.GetPrevGroup(m_Group < 1 ? 1 : m_Group);
            if (m_Group < 0)
                m_Group = SaveGroup;
            cChannel *channel = Channels.Get(m_Group);
            if (channel) {
                m_Channel = channel;
                Show(false, (OsdPipSetup.ShowInfo==0));
                if (!channel->GroupSep())
                    m_Group = -1;
            }
        }
        return osContinue;
    case kUp | k_Repeat:
    case kUp:
    case kDown | k_Repeat:
    case kDown:
        //std::cout << "cOsdInfoWindow::ProcessKey, vor cDevice::SwitchChannel" << std::endl;
        if (cDevice::SwitchChannel(NORMALKEY(key) == kUp ? 1 : -1));
        SetChannel(Channels.GetByNumber(cDevice::CurrentChannel()), false);
        //std::cout << "cOsdInfoWindow::ProcessKey, nach cDevice::SwitchChannel" << std::endl;
        m_WithInfo = true;
        m_Number = 0;
        m_Group = -1;
        Show(false, (OsdPipSetup.ShowInfo==0));
        return osContinue;
        //case kChanUp|k_Repeat:
        //case kChanUp:
        //case kChanDn|k_Repeat:
        //case kChanDn:
        //    m_WithInfo = true;
        //    m_Number = 0;
        //    m_Group = -1;
        //      return osContinue;//osUnknown;
    case kNone:
        if (Shown()) {
            time(&curTime);
            if (m_Number && curTime - m_LastTime > DIRECTCHANNELTIMEOUT) {
                if (Channels.GetByNumber(m_Number)) {
                    int number = m_Number;
                    m_Number = 0;
                    m_Group = -1;
                    //std::cout << "cOsdInfoWindow::ProcessKey, vor Channels.SwitchTo" << std::endl;
                    /* TB: only switch the channel if we are in live-view-mode, not when replaying recordings */
                    if(cDevice::PrimaryDevice()->Transferring()) {
                        Channels.SwitchTo(number);
                    }
                } else {
                    m_Number = 0;
                    m_Group = -1;
                    m_Channel = NULL;
                    Show(false, (OsdPipSetup.ShowInfo==0));
                    m_Channel = Channels.Get(cDevice::CurrentChannel());
                    m_WithInfo = true;
                    return osContinue;
                }
                return osContinue;
            }
        }
        break;
    case kOk:
        if (Shown()) {
            if (m_Group >= 0) {
                int group = m_Group;
                m_Group = -1;
                m_Number = 0;
                Channels.SwitchTo(Channels.Get(Channels.GetNextNormal(group))->Number());
            } else {
                m_Group = -1;
                m_Number = 0;
                m_Channel = Channels.Get(cDevice::CurrentChannel());
                m_WithInfo = true;
                Hide();
            }
            return osContinue;
        }
        break;
    default:
        return osUnknown;
    }
    if (Shown()) {
        time(&curTime);
        if (curTime - m_LastTime >= INFOTIMEOUT) {
            m_Group = -1;
            m_Number = 0;
            Hide();
        }
        return osContinue;
    }
    return osContinue;
}
Пример #26
0
void Normalization::Load(char *pFile)
{
   if(strlen(pFile) == 0 && strcmp(pFile, "none") != 0)
   {
      return;
   }

   mParams.clear();

   SXMLDocument doc;
   doc.Load(pFile);
   SXMLNode &root_node = doc.GetRootNode();

   root_node.FirstChild();

   SXMLNode *pchannel_node;
   while((pchannel_node = root_node.GetChild()) != 0)
   {
      if(pchannel_node->GetName() == "channel")
      {
         int id = 0;
         sscanf((char *)(*pchannel_node->GetProperties())["id"].c_str(), "%d", &id);
         SetChannel(id);

         pchannel_node->FirstChild();

         SXMLNode *pchild_node;
         while((pchild_node = pchannel_node->GetChild()) != 0)
         {
            std::string name = pchild_node->GetName();
            std::string text = pchild_node->GetText();
            if(name == "mean")
            {
               float *pvct;
               int len;

               ParseFloatVector((char *)text.c_str(), &pvct, &len);

               if(len != mpActualParams->GetFrameLength())
               {
                  mpActualParams->Alloc(len);
                  mpActualParams->Null();
               }

               mpActualParams->SetMeans(pvct);
               delete [] pvct;
            }
            else if(name == "variance")
            {
               float *pvct;
               int len;

               ParseFloatVector((char *)text.c_str(), &pvct, &len);

               int i;
               for(i = 0; i < len; i++)
               {
                  pvct[i] = 1.0f / sqrt(pvct[i]);
               } 

               if(len != mpActualParams->GetFrameLength())
               {
                  mpActualParams->Alloc(len);
                  mpActualParams->Null();
               }

               mpActualParams->SetInvStds(pvct);
               delete [] pvct;
            }
            else if(name == "gvariance")
            {
               float *pvct;
               int len;

               ParseFloatVector((char *)text.c_str(), &pvct, &len);

               int i;
               for(i = 0; i < len; i++)
               {
                  pvct[i] = sqrt(pvct[i]);
               } 

               if(len != mpActualParams->GetFrameLength())
               {
                  mpActualParams->Alloc(len);
                  mpActualParams->Null();
               }

               mpActualParams->SetGlobStds(pvct);
               delete [] pvct;
            }
         }
      }  
   }
  
   SetChannel(0);
}
Пример #27
0
// Author & Date:   Ehsan Azar     30 March 2011
// Purpose: Current channel changed
void CSDKSampleDlg::OnSelchangeComboChannel()
{
    UINT16 newchan = m_cboChannel.GetCurSel() + 1;
    if (newchan != m_channel)
        SetChannel(newchan);
}
Пример #28
0
                       printf("Loading alignment HMM set %s\n",q);

                   }

                   AddMMF(&al_hset,q);

                   if (eos)

                       break;

                   q=p+1;

               }

               p++;

           }

       }

       if (strlen(al_hmmLst) > 0 ) 

           MakeHMMSet(&al_hset, al_hmmLst );

       else /* use same hmmList */

           MakeHMMSet(&al_hset, hmmListFn );

       if (strlen(al_hmmDir) > 0 )

           LoadHMMSet(&al_hset,al_hmmDir,al_hmmExt);

       else

           LoadHMMSet(&al_hset,NULL,NULL);



       /* switch model set */

       UseAlignHMMSet(fbInfo,x,&al_hset);

       if (parMode != 0) {

	  ConvDiagC(&al_hset,TRUE);

	  ConvLogWt(&al_hset);

       }



       /* and echo status */

       if (trace&T_TOP) { 

           if (strlen(al_hmmDir) > 0 )

               printf(" HMM Dir %s",al_hmmDir);

           if (strlen(al_hmmExt) > 0 )

               printf(" Ext %s",al_hmmExt);
Пример #29
0
void ControlToolBar::OnRecord(wxCommandEvent &evt)
{
   auto doubleClicked = mRecord->IsDoubleClicked();
   mRecord->ClearDoubleClicked();

   if (doubleClicked) {
      // Display a fixed recording head while scrolling the waves continuously.
      // If you overdub, you may want to anticipate some context in existing tracks,
      // so center the head.  If not, put it rightmost to display as much wave as we can.
      const auto project = GetActiveProject();
      bool duplex;
      gPrefs->Read(wxT("/AudioIO/Duplex"), &duplex, true);

      if (duplex) {
         // See if there is really anything being overdubbed
         if (gAudioIO->GetNumPlaybackChannels() == 0)
            // No.
            duplex = false;
      }

      using Mode = AudacityProject::PlaybackScroller::Mode;
      project->GetPlaybackScroller().Activate(duplex ? Mode::Centered : Mode::Right);
      return;
   }

   if (gAudioIO->IsBusy()) {
      if (!CanStopAudioStream() || 0 == gAudioIO->GetNumCaptureChannels())
         mRecord->PopUp();
      else
         mRecord->PushDown();
      return;
   }
   AudacityProject *p = GetActiveProject();

   if( evt.GetInt() == 1 ) // used when called by keyboard shortcut. Default (0) ignored.
      mRecord->SetShift(true);
   if( evt.GetInt() == 2 )
      mRecord->SetShift(false);

   SetRecord(true, mRecord->WasShiftDown());

   if (p) {
      TrackList *trackList = p->GetTracks();
      TrackListIterator it(trackList);
      if(it.First() == NULL)
         mRecord->SetShift(false);
      double t0 = p->GetSel0();
      double t1 = p->GetSel1();
      if (t1 == t0)
         t1 = 1000000000.0;     // record for a long, long time (tens of years)

      /* TODO: set up stereo tracks if that is how the user has set up
       * their preferences, and choose sample format based on prefs */
      WaveTrackArray newRecordingTracks, playbackTracks;
#ifdef EXPERIMENTAL_MIDI_OUT
      NoteTrackArray midiTracks;
#endif
      bool duplex;
      gPrefs->Read(wxT("/AudioIO/Duplex"), &duplex, true);

      if(duplex){
         playbackTracks = trackList->GetWaveTrackArray(false);
#ifdef EXPERIMENTAL_MIDI_OUT
         midiTracks = trackList->GetNoteTrackArray(false);
#endif
     }
      else {
         playbackTracks = WaveTrackArray();
#ifdef EXPERIMENTAL_MIDI_OUT
         midiTracks = NoteTrackArray();
#endif
     }

      // If SHIFT key was down, the user wants append to tracks
      int recordingChannels = 0;
      TrackList tracksCopy{};
      bool tracksCopied = false;
      bool shifted = mRecord->WasShiftDown();
      if (shifted) {
         bool sel = false;
         double allt0 = t0;

         // Find the maximum end time of selected and all wave tracks
         // Find whether any tracks were selected.  (If any are selected,
         // record only into them; else if tracks exist, record into all.)
         for (Track *tt = it.First(); tt; tt = it.Next()) {
            if (tt->GetKind() == Track::Wave) {
               WaveTrack *wt = static_cast<WaveTrack *>(tt);
               if (wt->GetEndTime() > allt0) {
                  allt0 = wt->GetEndTime();
               }

               if (tt->GetSelected()) {
                  sel = true;
                  if (wt->GetEndTime() > t0) {
                     t0 = wt->GetEndTime();
                  }
               }
            }
         }

         // Use end time of all wave tracks if none selected
         if (!sel) {
            t0 = allt0;
         }

         // Pad selected/all wave tracks to make them all the same length
         // Remove recording tracks from the list of tracks for duplex ("overdub")
         // playback.
         for (Track *tt = it.First(); tt; tt = it.Next()) {
            if (tt->GetKind() == Track::Wave && (tt->GetSelected() || !sel)) {
               WaveTrack *wt = static_cast<WaveTrack *>(tt);
               if (duplex) {
                  auto end = playbackTracks.end();
                  auto it = std::find(playbackTracks.begin(), end, wt);
                  if (it != end)
                     playbackTracks.erase(it);
               }
               t1 = wt->GetEndTime();
               if (t1 < t0) {
                  if (!tracksCopied) {
                     tracksCopied = true;
                     tracksCopy = *trackList;
                  }

                  auto newTrack = p->GetTrackFactory()->NewWaveTrack();
                  newTrack->InsertSilence(0.0, t0 - t1);
                  newTrack->Flush();
                  wt->Clear(t1, t0);
                  bool bResult = wt->Paste(t1, newTrack.get());
                  wxASSERT(bResult); // TO DO: Actually handle this.
                  wxUnusedVar(bResult);
               }
               newRecordingTracks.push_back(wt);
            }
         }

         t1 = 1000000000.0;     // record for a long, long time (tens of years)
      }
      else {
         bool recordingNameCustom, useTrackNumber, useDateStamp, useTimeStamp;
         wxString defaultTrackName, defaultRecordingTrackName;
         int numTracks = 0;

         for (Track *tt = it.First(); tt; tt = it.Next()) {
            if (tt->GetKind() == Track::Wave && !tt->GetLinked())
               numTracks++;
         }
         numTracks++;
         
         recordingChannels = gPrefs->Read(wxT("/AudioIO/RecordChannels"), 2);

         gPrefs->Read(wxT("/GUI/TrackNames/RecordingNameCustom"), &recordingNameCustom, false);
         gPrefs->Read(wxT("/GUI/TrackNames/TrackNumber"), &useTrackNumber, false);
         gPrefs->Read(wxT("/GUI/TrackNames/DateStamp"), &useDateStamp, false);
         gPrefs->Read(wxT("/GUI/TrackNames/TimeStamp"), &useTimeStamp, false);
         /* i18n-hint: The default name for an audio track. */
         gPrefs->Read(wxT("/GUI/TrackNames/DefaultTrackName"),&defaultTrackName, _("Audio Track"));
         gPrefs->Read(wxT("/GUI/TrackNames/RecodingTrackName"), &defaultRecordingTrackName, defaultTrackName);

         wxString baseTrackName = recordingNameCustom? defaultRecordingTrackName : defaultTrackName;

         for (int c = 0; c < recordingChannels; c++) {
            auto newTrack = p->GetTrackFactory()->NewWaveTrack();

            newTrack->SetOffset(t0);
            wxString nameSuffix = wxString(wxT(""));

            if (useTrackNumber) {
               nameSuffix += wxString::Format(wxT("%d"), numTracks + c);
            }

            if (useDateStamp) {
               if (!nameSuffix.IsEmpty()) {
                  nameSuffix += wxT("_");
               }
               nameSuffix += wxDateTime::Now().FormatISODate();
            }

            if (useTimeStamp) {
               if (!nameSuffix.IsEmpty()) {
                  nameSuffix += wxT("_");
               }
               nameSuffix += wxDateTime::Now().FormatISOTime();
            }

            // ISO standard would be nice, but ":" is unsafe for file name.
            nameSuffix.Replace(wxT(":"), wxT("-"));

            if (baseTrackName.IsEmpty()) {
               newTrack->SetName(nameSuffix);
            }
            else if (nameSuffix.IsEmpty()) {
               newTrack->SetName(baseTrackName);
            }
            else {
               newTrack->SetName(baseTrackName + wxT("_") + nameSuffix);
            }

            if (recordingChannels > 2)
              newTrack->SetMinimized(true);

            if (recordingChannels == 2) {
               if (c == 0) {
                  newTrack->SetChannel(Track::LeftChannel);
                  newTrack->SetLinked(true);
               }
               else {
                  newTrack->SetChannel(Track::RightChannel);
               }
            }
            else {
               newTrack->SetChannel( Track::MonoChannel );
            }

            // Let the list hold the track, and keep a pointer to it
            newRecordingTracks.push_back(
               static_cast<WaveTrack*>(
                  trackList->Add(
                     std::move(newTrack))));
         }
      }

      //Automated Input Level Adjustment Initialization
      #ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
         gAudioIO->AILAInitialize();
      #endif

      AudioIOStartStreamOptions options(p->GetDefaultPlayOptions());
      int token = gAudioIO->StartStream(playbackTracks,
                                        newRecordingTracks,
#ifdef EXPERIMENTAL_MIDI_OUT
                                        midiTracks,
#endif
                                        t0, t1, options);

      bool success = (token != 0);

      if (success) {
         p->SetAudioIOToken(token);
         mBusyProject = p;
      }
      else {
         if (shifted) {
            // Restore the tracks to remove any inserted silence
            if (tracksCopied)
               *trackList = std::move(tracksCopy);
         }
         else {
            // msmeyer: Delete recently added tracks if opening stream fails
            for (unsigned int i = 0; i < newRecordingTracks.size(); i++) {
               trackList->Remove(newRecordingTracks[i]);
            }
         }

         // msmeyer: Show error message if stream could not be opened
         wxMessageBox(_("Error while opening sound device. Please check the recording device settings and the project sample rate."),
                      _("Error"), wxOK | wxICON_EXCLAMATION, this);

         SetPlay(false);
         SetStop(false);
         SetRecord(false);
      }
   }
   UpdateStatusBar(GetActiveProject());
}
Пример #30
0
bool ofxCrazyradio::init() {
  int ret = libusb_init(&ctx_);
//  std::cout << "libusb_init: " << ret << std::endl;
//  libusb_set_debug(ctx_, 3);
  
  bool found = false;
  libusb_device **list;
  ssize_t count = libusb_get_device_list(ctx_, &list);
//  std::cout << "libusb_get_device_list: " << count << std::endl;
  for (int i = 0; i < count; i++) {
    struct libusb_device_descriptor desc;
    ret = libusb_get_device_descriptor(list[i], &desc);
    if (desc.idVendor == 0x1915 && desc.idProduct == 0x7777) {
      found = true;
      ret = libusb_open(list[i], &handle_);
//      std::cout << "libusb_open: " << ret << std::endl;
      
//      std::cout << "version: " << std::hex << desc.bcdDevice << std::dec << std::endl;
      
//      uint8_t string_desc[256];
//      ret = libusb_get_string_descriptor_ascii(handle_, desc.iManufacturer, string_desc, 256);
//      std::cout << "libusb_get_string_descriptor_ascii: " << ret << std::endl;
//      std::cout << string_desc << std::endl;
//
      
//      for (int n = 0; n < desc.bNumConfigurations; n++) {
//        libusb_config_descriptor *config_desc;
//        const libusb_interface_descriptor *inter_desc;
//        const libusb_endpoint_descriptor *ep_desc;
//        const libusb_interface *inter;
//        libusb_get_config_descriptor(list[i], n, &config_desc);
//        std::cout << "config: " << (int)config_desc->bConfigurationValue << std::endl;
//        std::cout << "bNumInterfaces: " << (int)config_desc->bNumInterfaces << std::endl;
//        for (int i = 0; i < (int)config_desc->bNumInterfaces; i++) {
//          inter = &config_desc->interface[i];
//          std::cout << "  num_altsetting: " << inter->num_altsetting << std::endl;
//          for (int j = 0; j < inter->num_altsetting; j++) {
//            inter_desc = &inter->altsetting[j];
//            std::cout << "    Interface number: " << (int)inter_desc->bInterfaceNumber << std::endl;
//            std::cout << "    number of endpoint: " << (int)inter_desc->bNumEndpoints << std::endl;
//            for (int k = 0; k < (int)inter_desc->bNumEndpoints; k++) {
//              ep_desc = &inter_desc->endpoint[k];
//              std::cout << "     desc type: " << (int)ep_desc->bDescriptorType << std::endl;
//              std::cout << "     ep address: " << (int)ep_desc->bEndpointAddress << std::endl;
//              std::cout << "     attributes: " << std::hex << (int)ep_desc->bmAttributes << std::dec << std::endl;
//            }
//          }
//        }
//      }
      
//      ret = libusb_kernel_driver_active(handle_, 0);
//      std::cout << "libusb_kernel_driver_active: " << ret << std::endl;
      
      ret = libusb_claim_interface(handle_, 0);
//      std::cout << "libusb_claim_interface: " << ret << std::endl;
      
      libusb_set_configuration(handle_, 1);
      SetDataRate(DR_250KPS);
      SetChannel(2);
      arc_ = -1;
      SetContCarrier(false);
      uint8_t address[] = "\xe7\xe7\xe7\xe7\xe7";
      SetAddress(address);
      SetPower(P_0DBM);
      SetArc(3);
      SetArdBytes(32);
      break;
    }
  }
  libusb_free_device_list(list, 1);
  
  return found;
}