Esempio n. 1
0
void testWithinLimitsPasses(void)
{
	SetFrequency(MAX_FREQ);
	TEST_ASSERT_EQUAL(MAX_FREQ, GetFrequency());
	SetFrequency(MIN_FREQ);
	TEST_ASSERT_EQUAL(MIN_FREQ, GetFrequency());
}
void StepperMotor_Start (CStepperMotor* motor, CStepperDirection direction)
{
    motor->direction = direction;

    motor->time = sqrtf ((2.0f / motor->accelerationGradient));
    motor->decelTime = 0.0f;

    motor->pwmChannel->SetFrequency (GetFrequency (
    motor->time, &motor->accelerationGradient, &motor->accelerationOffset));

    motor->stepCount = 0;

    motor->time +=
    1.0f / GetFrequency (motor->time, &motor->accelerationGradient,
                         &motor->accelerationOffset);

    motor->state = STEPPER_STATE_ACCELERATING;

    switch (motor->direction)
    {
    case STEPPER_DIRECTION_FORWARD:
        motor->actions->Forward ();
        break;

    case STEPPER_DIRECTION_REVERSE:
        motor->actions->Reverse ();
        break;
    }

    motor->actions->Enable ();

    motor->pwmChannel->Start ();
}
Esempio n. 3
0
void TNote::Slide(TNote aNote)
{
	int i, n = 0;
	int FromFrequency, ToFrequency;
	if (GetFrequency() < aNote.GetFrequency())
	{
		FromFrequency = GetFrequency();
		ToFrequency = aNote.GetFrequency();
	}
	else
	{
		FromFrequency = aNote.GetFrequency();
		ToFrequency = GetFrequency();
	}
	Duration = Duration / 5;
	for (i = FromFrequency; i <= ToFrequency; i = i + (ToFrequency - FromFrequency) / 5)
	{
		SetFrequency(i);
		PrintParameters(0, 0, 0);
		std::cout << n << ' ';
		n++;
		Play();
	}
	Duration = Duration * 5;
}
void StepperMotor::BeginMove ()
{
    time = sqrtf ((2.0f / accelerationGradient));
    decelTime = 0.0f;

    frequencyChannel.SetFrequency (
    GetFrequency (time, &accelerationGradient, &accelerationOffset));

    stepCount = 0;

    time +=
    1.0f / GetFrequency (time, &accelerationGradient, &accelerationOffset);

    state = State::Accelerating;

    switch (direction)
    {
    case Direction::Forward:
        actions.Forward ();
        break;

    case Direction::Reverse:
        actions.Reverse ();
        break;
    }

    actions.Enable ();

    frequencyChannel.Start ();
}
Esempio n. 5
0
TTaskResult CBeep::Execute(CRobot * Robot, CExecutableRWGraphicObjectList * ExecutableObjectList, bool & result)
{
    if (Robot->GetSoftwareRevision() <= 1.06)   /*Do the tune as beeps for robots before version 1.07*/
    {
        Robot->AddBeepToInstructions(GetFrequency(), GetDuration());
        CFlowZap *FZ = (CFlowZap*)m_fc;
        CBeep* LastBeep = this;
        CInstruction *Next = FZ->GetNextInstructionInList(this);

        //	Next = FZ->GetNextExecutableInstruction(Next);
        while (Next->IsKindOf(RUNTIME_CLASS(CBeep)))
        {
            LastBeep = (CBeep*)Next;
            Robot->AddBeepToInstructions(LastBeep->GetFrequency(), LastBeep->GetDuration());
            Next = FZ->GetNextInstructionInList(Next);
            //		Next = FZ->GetNextExecutableInstruction(Next);
        }

        FZ->SetCueToInstruction(LastBeep);
        FZ->RedrawWindow();
    }
    else
    {
        unsigned int NumberOfNotes = 1;
        CArray<short, short> FrequencyList;
        FrequencyList.SetSize(20, 20);
        CArray<int, int> DurationList;
        DurationList.SetSize(20, 20);
        FrequencyList[0] = GetFrequency();
        DurationList[0] = GetDuration();
        CFlowZap *FZ = (CFlowZap*)m_fc;
        CBeep* LastBeep = this;
        CInstruction *Next = FZ->GetNextInstructionInList(this);

        //	Next = FZ->GetNextExecutableInstruction(Next);
        while (Next->IsKindOf(RUNTIME_CLASS(CBeep)))
        {
            LastBeep = (CBeep*)Next;
            FrequencyList[NumberOfNotes] = LastBeep->GetFrequency();
            DurationList[NumberOfNotes] = LastBeep->GetDuration();
            NumberOfNotes++;
            Next = FZ->GetNextInstructionInList(Next);
            //		Next = FZ->GetNextExecutableInstruction(Next);
        }

        FrequencyList[NumberOfNotes] = -1;
        DurationList[NumberOfNotes] = 0;
        NumberOfNotes++;
        Robot->AddTuneToInstructions(FrequencyList.GetData(), DurationList.GetData(), NumberOfNotes);

        FZ->SetCueToInstruction(LastBeep);
        FZ->RedrawWindow();
    }

    TTaskResult TaskResult;
    TaskResult = Robot->FollowInstructions(true, true, IR_InstructionComplete);
    return TaskResult;
}
Esempio n. 6
0
unsigned int cSoundStream::CalculateChunkSize()
{
    switch(GetFormat())
    {
    case AL_FORMAT_MONO8: return GetFrequency() * 2;
    case AL_FORMAT_STEREO8: return GetFrequency() * 2 * 2;
    case AL_FORMAT_MONO16: return GetFrequency() * 2 * 2;
    case AL_FORMAT_STEREO16: return GetFrequency() * 4 * 2;
    }

    return 0;
}
Esempio n. 7
0
void do_menu(uint8_t func_number) {

//    lcd_MEM2_string(DoMenu_str);	// "do menu "
//    u2lcd(func_number);
    if (func_number == MODE_FREQ) GetFrequency(0);
#if PROCESSOR_TYP == 644
    if (func_number == MODE_HFREQ) GetFrequency(1);	// measure high frequency with 16:1 divider
    if (func_number == MODE_H_CRYSTAL) GetFrequency(5); // HF crystal input + 16:1 divider
    if (func_number == MODE_L_CRYSTAL) GetFrequency(6); // LF crystal input, 1:1 divider
#endif
    if (func_number == MODE_FGEN) {
       make_frequency();		// make some sample frequencies
    }
    if (func_number == MODE_PWM) {
       do_10bit_PWM();		// generate 10bit PWM
    }
    if (func_number == MODE_ESR) {
       show_C_ESR();		// measure capacity and ESR at TP1 and TP3
    }
    if (func_number == MODE_RESIS) {
       show_Resis13();		// measure resistor at TP1 and TP3
    }
    if (func_number == MODE_CAP13) {
   lcd_clear();
       show_Cap13();		// measure capacitor at TP1 and TP3
    }
#ifdef WITH_ROTARY_CHECK
    if (func_number == MODE_ROTARY) {
       CheckRotaryEncoder();		// check rotary encoder
    }
#endif
    if (func_number == MODE_BIG_CAP_CORR) {
       set_big_cap_corr();
    }
#ifdef WITH_SELFTEST
    if (func_number == MODE_SELFTEST) AutoCheck(0x11);	// Full selftest with calibration
#endif
    if (func_number == MODE_VEXT) show_vext();
#if ((LCD_ST_TYPE == 7565) || (LCD_ST_TYPE == 1306) || (LCD_ST_TYPE == 8812) || (LCD_ST_TYPE == 8814) || defined(LCD_DOGM))
    if (func_number == MODE_CONTRAST) set_contrast();
#endif
    if (func_number == MODE_SHOW) {
       ShowData();			// Show Calibration Data
    }
    if (func_number == MODE_OFF) {
       ON_PORT &= ~(1<<ON_PIN);              //switch off power
       wait_for_key_ms(0); //never ending loop
    }
}
Esempio n. 8
0
/*****************************************************************************
 * Function - UpdateFlowLearnControl
 * DESCRIPTION:
 *
 *****************************************************************************/
void AdvancedFlowCtrl::UpdateFlowLearnControl(PUMP_TYPE pumpNo)
{
  AFC_RUN_FLOW_LEARN_STRUCT run_learn;

  if (mConfigurationIsUpdated[pumpNo] == true)
  {
    float min_frequency, max_frequency;
    if (mpVfdInstalled[pumpNo]->GetValue() == true)
    {
      min_frequency = mpVfdMinFrequency[pumpNo]->GetValue();
      max_frequency = mpVfdMaxFrequency[pumpNo]->GetValue();
    }
    else
    {
      min_frequency = mpVfdFrequency[pumpNo]->GetMaxValue();
      max_frequency = min_frequency;
    }
    mpFlowLearnControl[pumpNo]->SetFlowLearnParameters( mpPitStopLevel->GetValue(), mpPitStartLevel->GetValue(),
                                                        min_frequency, max_frequency);
    mConfigurationIsUpdated[pumpNo] = false;
  }

  if (mPumpLearningState[pumpNo] == FLOW_LEARNING_RUNNING)
  {
    run_learn.level = mpSurfaceLevel->GetValue();
    run_learn.speed = GetFrequency(pumpNo);
    run_learn.pumpState = mPumpState[pumpNo];
    mpFlowLearnControl[pumpNo]->CtrlFlowLearnControl(&run_learn);
  }
}
Esempio n. 9
0
namespace Clock {

int64 GetFrequency() {
  LARGE_INTEGER large_integer;
  VERIFY_TRUE(QueryPerformanceFrequency(&large_integer), "QueryPerformanceFrequency failed");
  return large_integer.QuadPart;
}

int64 GetStartTime() {
  LARGE_INTEGER large_integer;
  VERIFY_TRUE(QueryPerformanceCounter(&large_integer), "QueryPerformanceCounter failed");
  return large_integer.QuadPart;
}

int64 g_frequency_ = GetFrequency();
int64 g_start_time_ = GetStartTime();

HighResolutionClock::Repr HighResolutionClock::TimeSinceEpoch() {
  LARGE_INTEGER large_integer;
  VERIFY_TRUE(QueryPerformanceCounter(&large_integer), "QueryPerformanceCounter failed");
  int64 nanosecond_count = (1000 * 1000 * 1000 * (large_integer.QuadPart - g_start_time_)) / g_frequency_;
  return nanosecond_count;
}

HighResolutionClock::TimePoint HighResolutionClock::Now() {
  LARGE_INTEGER large_integer;
  VERIFY_TRUE(QueryPerformanceCounter(&large_integer), "QueryPerformanceCounter failed");
  int64 nanosecond_count = (1000 * 1000 * 1000 * (large_integer.QuadPart - g_start_time_)) / g_frequency_;
  return TimePoint(HighResolutionClock::Duration(nanosecond_count));
}

}  // namespace Elg
Esempio n. 10
0
LRESULT CMainDlg::OnSaveWave(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	char fileName[MAX_PATH];
	memset(fileName, 0, sizeof(fileName));
	OPENFILENAME ofn;
	memset(&ofn, 0, sizeof(ofn));
	ofn.lStructSize = sizeof(ofn);
	ofn.hwndOwner = m_hWnd;
	ofn.lpstrFilter = "Sound Files(*.wav)\0*.wav\0All Files(*.*)\0*.*\0";
	ofn.nFilterIndex = 1;
	ofn.lpstrFile = fileName;
	ofn.lpstrDefExt = ".wav";
	ofn.nMaxFile = MAX_PATH;
	ofn.Flags = OFN_OVERWRITEPROMPT;
	
	if (GetSaveFileName (&ofn))
	{
		double frq = GetFrequency();
		GenWaveI wv;
		wv.InitWT(frq, WT_USR(0));
		EnvGen eg;
		eg.InitEG(1.0, 2.0, 0.05, 0.05);
		WaveFile wvf;
		wvf.OpenWaveFile(fileName, 2);
		long totalSamples = (long) (2.0 * synthParams.sampleRate);
		for (long n = 0; n < totalSamples; n++)
			wvf.Output1(eg.Gen() * wv.Gen());
		wvf.CloseWaveFile();

	}
	return 0;
}
Esempio n. 11
0
//___________________________________________________________________________________________
Bool_t KVIntegerList::Contains(Int_t val) const
{
//Retourne kTRUE si la valeur "val" est dans la liste, kFALSE sinon
//dans la liste retourne -1
   return (GetFrequency(val) > 0);

}
Esempio n. 12
0
int CMpegFrame::GetFrameSize() const
{
  int nSlots = (int)(144.0 * (double)GetBitrate() / (double)GetFrequency() );
  // static UINT16 bPrePadding = 2;	// ## Paddingの値が変わったときを出力するために使う
  //  static int nEachPadding = 0;	// ## paddingごとにフレームサイズの和を出力する

  if( m_nPaddingBit ){
    nSlots++;
  }

  /************* ## ここはデバッグ用 ******************/
  
  //   if(bPrePadding != m_nPaddingBit){
  //     if(m_nPaddingBit){
  //       std::cout << "\n## Padding. Frame size = " << nSlots << "\n";
  //     }
  //     else{				// ## Debug
  //       std::cout << "\n## Not Padding. Frame size = " << nSlots << "\n";
  //     }
  //     bPrePadding = m_nPaddingBit;
  //   }
  
  // ## 別デバッグ
//   nEachPadding += nSlots;
//   if(!m_nPaddingBit){
//     std::cout << "\n## nEachPadding = " << nEachPadding << "\n";
//     nEachPadding = 0;
//   }


  /************************************/
  return nSlots;
}
wxString mmBillsDepositsPanel::getItem(long item, long column)
{
    const Model_Billsdeposits::Full_Data& bill = this->bills_.at(item);
    switch (column)
    {
    case COL_ID:
        return wxString::Format("%i", bill.BDID).Trim();
    case COL_PAYMENT_DATE:
        return mmGetDateForDisplay(Model_Billsdeposits::NEXTOCCURRENCEDATE(bill));
    case COL_DUE_DATE:
        return mmGetDateForDisplay(Model_Billsdeposits::TRANSDATE(bill));
    case COL_ACCOUNT:
        return bill.ACCOUNTNAME;
    case COL_PAYEE:
        return bill.PAYEENAME;
    case COL_STATUS:
        return bill.STATUS;
    case COL_CATEGORY:
        if (bill.has_split())
            return _("Split.......");
        else
            return bill.CATEGNAME;
    case COL_TYPE:
        return wxGetTranslation(bill.TRANSCODE);
    case COL_AMOUNT:
        return Model_Account::toCurrency(bill.TRANSAMOUNT, Model_Account::instance().get(bill.ACCOUNTID));
    case COL_FREQUENCY:
        return GetFrequency(&bill);
    case COL_REPEATS:
        if (bill.NUMOCCURRENCES == -1)
            return L"\x221E";
        else
            return wxString::Format("%i", bill.NUMOCCURRENCES).Trim();
    case COL_AUTO:
    {
        int repeats = bill.REPEATS;
        wxString repeatSTR = _("Manual");
        if (repeats >= BD_REPEATS_MULTIPLEX_BASE)
        {
            repeats -= BD_REPEATS_MULTIPLEX_BASE;
            repeatSTR = _("Suggested");
            if (repeats >= BD_REPEATS_MULTIPLEX_BASE)
            {
                repeats -= BD_REPEATS_MULTIPLEX_BASE;
                repeatSTR = _("Automated");
            }
        }
        return repeatSTR;
    }
    case COL_DAYS:
        return GetRemainingDays(&bill);
    case COL_NUMBER:
        return bill.TRANSACTIONNUMBER;
    case COL_NOTES:
        return bill.NOTES;
    default:
        return wxEmptyString;
    }
}
Esempio n. 14
0
	int Buffer::GetFrequency() const
	{
	    #ifdef HAS_AUDIO_BUFFER
		return impl->GetFrequency();
		#else
		throw System::PunkException(L"Audio buffer not supported");
		#endif
	}
Esempio n. 15
0
void OMXClock::CheckSystemClock()
{
  if(!m_systemFrequency)
    m_systemFrequency = GetFrequency();

  if(!m_systemOffset)
    m_systemOffset = GetTime();
}
Esempio n. 16
0
int CTimer::RandomSeed()
{
#ifdef _WIN32
    return GetPerformanceCount() / GetFrequency();
#else
    return 0;
#endif
}
Esempio n. 17
0
int AudioFormat_YM::GetPosition()
	{
	if (!ymFile_)
		{
		return 0;
		}
	return (int)((ymFile_->getPos()/1000.0f)*GetChannels()*(GetBitsPerSample()/8)*GetFrequency());
	}
Esempio n. 18
0
CTimer::TimeUnits CTimer::Stop()
{
    if( !QueryPerformanceCounter( (LARGE_INTEGER*)&m_endTime) )
    {
        THOT_ASSERT(false, "CTimer: Failed to get end time");
    }

    return (CTimer::TimeUnits)( m_endTime - m_startTime) / (GetFrequency().QuadPart/1000000);
}
Esempio n. 19
0
/*****************************************************************************
 * Function - UpdatePumpState
 * DESCRIPTION:
 *
 *****************************************************************************/
void AdvancedFlowCtrl::UpdatePumpState(PUMP_TYPE pumpNo)
{
  switch (mpOperationMode[pumpNo]->GetValue())
  {
    case ACTUAL_OPERATION_MODE_STOPPED:
      mPumpState[pumpNo] = AFC_PUMP_STOPPED;
      break;

    case ACTUAL_OPERATION_MODE_STARTED:
      if (mpVfdState[pumpNo]->GetValue() == VFD_OPERATION_MODE_REV_FLUSH)
      {
        mPumpState[pumpNo] = AFC_PUMP_STOPPED;
      }
      else
      {
        if (mPumpState[pumpNo] != AFC_PUMP_RUNNING)
        {
          mPumpState[pumpNo] = AFC_PUMP_RUNNING;
          mPumpStartedEvent[pumpNo] = true;
        }
      }
      break;

    default:
      // ACTUAL_OPERATION_MODE_DISABLED:
      // ACTUAL_OPERATION_MODE_NOT_INSTALLED:
      mPumpState[pumpNo] = AFC_PUMP_NOT_THERE;
      break;
  }

  if (mPumpState[pumpNo] != AFC_PUMP_RUNNING)
  {
    if (mpCUEFrequency[pumpNo]->GetQuality() == DP_AVAILABLE)
    {
      // Initialize to a short delay since the wait time is counted after ramping up
      mAwaitPumpRampUpTime[pumpNo] = 2;
    }
    else
    {
      // Initialize to a longer delay. (3-8 seconds, but we really don't know)
      mAwaitPumpRampUpTime[pumpNo] = 5;
    }
  }
  else // Pump is running, determine when ramp up has passed
  {
    if (mAwaitPumpRampUpTime[pumpNo] > 0)
    {
      float ref_frequency = mpVfdFrequency[pumpNo]->GetValue();
      if ( (mpCUEFrequency[pumpNo]->GetQuality() != DP_AVAILABLE)
        || (ref_frequency > 0.0f && GetFrequency(pumpNo) >= 0.95f*ref_frequency) )
      {
        mAwaitPumpRampUpTime[pumpNo]--;
      }
    }
  }
}
Esempio n. 20
0
void AudioFormat_YM::SetPosition(int position)
	{
	if (!ymFile_)
		{
		return;
		}
	float sampleSize=(float)(GetChannels()*GetFrequency()*(GetBitsPerSample()/8));
	float time=position/sampleSize;
	ymFile_->setMusicTime((int)(time*1000.0f));
	}
Esempio n. 21
0
//___________________________________________________________________________________________
Bool_t KVIntegerList::RemoveAll(Int_t val)
{
//Reture completement la valeur val
//la methode retourne kTRUE si cette valeur etait effectivement presente, kFALSE sinon
//
//Le bit kHastobeComputed es mis à 1 pour indiquer la nécéssité de mettre a jour la partition
//voir KVIntegerList::CheckForUpdate()
//

   return Remove(val, GetFrequency(val));
}
Esempio n. 22
0
/*****************************************************************************
 * Function - GetSpeed
 * DESCRIPTION:
 *****************************************************************************/
float AdvancedFlowCtrl::GetSpeed(int pumpIndex)
{
  float speed = 0.0f;
  if (pumpIndex < NO_OF_PUMPS && mpPower[pumpIndex]->IsAvailable())
  {
    float power = mpPower[pumpIndex]->GetValue();
    float frequency = GetFrequency(pumpIndex);
    speed = mpMotorModel->GetShaftSpeed(power, frequency);
  }
  return speed;
}
Esempio n. 23
0
/**
 * Fetch a list of all FTDI widgets and create a new device for each of them.
 */
bool FtdiDmxPlugin::StartHook() {
  typedef vector<FtdiWidgetInfo> FtdiWidgetInfoVector;
  FtdiWidgetInfoVector widgets;
  FtdiWidget::Widgets(&widgets);

  FtdiWidgetInfoVector::const_iterator iter;
  for (iter = widgets.begin(); iter != widgets.end(); ++iter) {
    AddDevice(new FtdiDmxDevice(this, *iter, GetFrequency()));
  }
  return true;
}
Esempio n. 24
0
Seconds  now()
{


  LARGE_INTEGER tick, freq;
  Seconds res;

  freq = GetFrequency();
  QueryPerformanceCounter(&tick);
  res = (Seconds)tick.QuadPart / (Seconds)freq.QuadPart;
  return res;
}
Esempio n. 25
0
LRESULT CMainDlg::OnLoop(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	UpdatePlot();
	double dur = 2.0;
	double frq = GetFrequency();
	if (Play(frq, dur, TRUE) == 0)
	{
		btnStop.EnableWindow(TRUE);
		btnPlay.EnableWindow(FALSE);
		btnLoop.EnableWindow(FALSE);
	}
	return 0;
}
Esempio n. 26
0
nglString nglVideoMode::Dump() const
{
  nglString str;
  uint freq = GetFrequency();

  str.Format(_T("%dx%dx%d"), GetWidth(), GetHeight(), GetDepth());
  if (freq)
  {
    nglString freq_str;
    
    freq_str.Format(_T(" (%d Hz)"), freq);
    str += freq_str;
  }
  return str;
}
/**
 * Enqueues a compilation for a new shader of this type.
 * @param Platform - The platform to compile for.
 * @param Material - The material to link the shader with.
 * @param VertexFactoryType - The vertex factory to compile with.
 */
FShaderCompileJob* FMeshMaterialShaderType::BeginCompileShader(
	uint32 ShaderMapId,
	EShaderPlatform Platform,
	const FMaterial* Material,
	FShaderCompilerEnvironment* MaterialEnvironment,
	FVertexFactoryType* VertexFactoryType,
	const FShaderPipelineType* ShaderPipeline,
	TArray<FShaderCommonCompileJob*>& NewJobs
	)
{
	FShaderCompileJob* NewJob = new FShaderCompileJob(ShaderMapId, VertexFactoryType, this);

	NewJob->Input.SharedEnvironment = MaterialEnvironment;
	FShaderCompilerEnvironment& ShaderEnvironment = NewJob->Input.Environment;

	// apply the vertex factory changes to the compile environment
	check(VertexFactoryType);
	VertexFactoryType->ModifyCompilationEnvironment(Platform, Material, ShaderEnvironment);

	//update material shader stats
	UpdateMaterialShaderCompilingStats(Material);

	UE_LOG(LogShaders, Verbose, TEXT("			%s"), GetName());
	COOK_STAT(MaterialMeshCookStats::ShadersCompiled++);

	// Allow the shader type to modify the compile environment.
	SetupCompileEnvironment(Platform, Material, ShaderEnvironment);

	bool bAllowDevelopmentShaderCompile = Material->GetAllowDevelopmentShaderCompile();

	// Compile the shader environment passed in with the shader type's source code.
	::GlobalBeginCompileShader(
		Material->GetFriendlyName(),
		VertexFactoryType,
		this,
		ShaderPipeline,
		GetShaderFilename(),
		GetFunctionName(),
		FShaderTarget(GetFrequency(),Platform),
		NewJob,
		NewJobs,
		bAllowDevelopmentShaderCompile
		);
	return NewJob;
}
Esempio n. 28
0
int AUDIOSOURCE::IsCompatible(AUDIOSOURCE* a)
{
	int i, j;
	__int64 k,l;

	k = FormatSpecific(MMSGFS_VORBIS_FRAMEDURATIONS);
	l = a->FormatSpecific(MMSGFS_VORBIS_FRAMEDURATIONS);

	if ((i=GetFormatTag()) && (j=a->GetFormatTag())) {
		if (i!=j || k!=l) return MMSIC_FORMATTAG;
	} else {
		if (strcmp(GetCodecID(),a->GetCodecID())) {
			return MMSIC_IDSTRING;
		}
	}

	if (a->GetFrequency() != GetFrequency()) return MMSIC_SAMPLERATE;
	
	return MMS_COMPATIBLE;
}
Esempio n. 29
0
void SequenceElements::ImportLyrics(Element* element, wxWindow* parent)
{
    LyricsDialog* dlgLyrics = new LyricsDialog(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize);

    if (dlgLyrics->ShowModal() == wxID_OK)
    {
        element->SetFixedTiming(0);
        // remove all existing layers from timing track
        int num_layers = element->GetEffectLayerCount();
        for( int k = num_layers-1; k >= 0; k-- )
        {
            element->RemoveEffectLayer(k);
        }
        EffectLayer* phrase_layer = element->AddEffectLayer();

        int total_num_phrases = dlgLyrics->TextCtrlLyrics->GetNumberOfLines();
        int num_phrases = total_num_phrases;
        for( int i = 0; i < dlgLyrics->TextCtrlLyrics->GetNumberOfLines(); i++ )
        {
            std::string line = dlgLyrics->TextCtrlLyrics->GetLineText(i).ToStdString();
            if( line == "" )
            {
                num_phrases--;
            }
        }
        int start_time = 0;
        int end_time = mSequenceEndMS;
        int interval_ms = (end_time-start_time) / num_phrases;
        for( int i = 0; i < total_num_phrases; i++ )
        {
            wxString line = dlgLyrics->TextCtrlLyrics->GetLineText(i).ToStdString();
            if( line != "" )
            {
                xframe->dictionary.InsertSpacesAfterPunctuation(line);
                end_time = TimeLine::RoundToMultipleOfPeriod(start_time+interval_ms, GetFrequency());
                phrase_layer->AddEffect(0,line.ToStdString(),"","",start_time,end_time,EFFECT_NOT_SELECTED,false);
                start_time = end_time;
            }
        }
    }
}
Esempio n. 30
0
bool Channel::SetBuffer(Buffer *buffer)
{
    if (!m_ready)
        return false;

    Stop();
    m_buffer = buffer;
    if (buffer == nullptr)
    {
        alSourcei(m_source, AL_BUFFER, 0);
        return true;
    }

    alSourcei(m_source, AL_BUFFER, buffer->GetBuffer());
    if (alCheck())
    {
        GetLogger()->Warn("Could not set sound buffer. Code: %d\n", alGetCode());
        return false;
    }
    m_initFrequency = GetFrequency();
    return true;
}