コード例 #1
0
ファイル: vf_Metronome.cpp プロジェクト: Izhaki/LayerEffects
  void setTickSample (void const* audioData, int dataBytes)
  {
    ScopedPointer <MemoryInputStream> mis (new MemoryInputStream (audioData, dataBytes, false));

    m_synth.clearVoices ();
    m_synth.clearSounds ();

    AudioFormatManager afm;
    afm.registerBasicFormats ();
    
    {
      ScopedPointer <AudioFormatReader> afr (afm.createReaderFor (mis));

      if (afr != nullptr)
      {
        mis.release ();

        BigInteger midiNotes;
        midiNotes.setRange (0, 127, true);

        SynthesiserSound::Ptr sound = new SamplerSound (
          "Tick",
          *afr,
          midiNotes,
          60,
          0,
          0,
          60./40.);

        m_synth.addSound (sound);
        m_synth.addVoice (new SamplerVoice);
      }
    }

  }
コード例 #2
0
ファイル: BigInteger.cpp プロジェクト: vgck/opendr2
BigInteger BigInteger::modExp(const BigInteger &power, const BigInteger &modulo, const BigInteger &recip, short nb) const
{
	BigInteger r;
	BigNum::modExp(r, *this, power, modulo,recip,nb);

	r.debugInitStr();
    return r;
}
コード例 #3
0
ファイル: BigInteger.cpp プロジェクト: vgck/opendr2
BigInteger BigInteger::modExp(const BigInteger &power, const BigInteger &modulo) const
{
	BigInteger r;
	BigNum::modExp(r, *this, power, modulo);

	r.debugInitStr();
    return r;
}
コード例 #4
0
ファイル: BigInteger.cpp プロジェクト: vgck/opendr2
BigInteger BigInteger::sub(const BigInteger &b) const
{
	BigInteger r;
	BigNum::sub(r, *this, b);

	r.debugInitStr();
    return r;
}
コード例 #5
0
ファイル: 424.cpp プロジェクト: Johniel/uva
 BigInteger operator - (BigInteger &in){
   if(sign() != in.sign())
     return add(*this, in, sign());
   else if(compare(in, true) == LESS)
     return sub(in, *this, in.sign());
   else
     return sub(*this, in, sign());
 }
コード例 #6
0
ファイル: 048-Powers.cpp プロジェクト: wrzimm/ProjectEuler
BigInteger *Pow(unsigned int x, unsigned int y){
	BigInteger *output = new BigInteger(n_digits,x);

	for(unsigned int i=2; i<=y; i++)
		output->Multiply(x);

	return output;
}
コード例 #7
0
void OptionsDialog::updateOutputChannelComboBox()
{
    m_ui->comboBox_OutputChannels->clear();

    if ( isJackAudioEnabled() )
    {
        m_ui->comboBox_OutputChannels->setVisible( false );
        m_ui->label_OutputChannels->setVisible( false );
    }
    else
    {
        m_ui->comboBox_OutputChannels->setVisible( true );
        m_ui->label_OutputChannels->setVisible( true );

        AudioIODevice* const currentAudioDevice = m_deviceManager.getCurrentAudioDevice();

        if ( currentAudioDevice != NULL )
        {
            m_ui->comboBox_OutputChannels->setEnabled( true );

            StringArray channelNames;
            channelNames = currentAudioDevice->getOutputChannelNames();
            StringArray channelPairNames;

            for ( int i = 0; i < channelNames.size(); i += 2 )
            {
                const String& name = channelNames[i];

                if ( i + 1 >= channelNames.size() )
                    channelPairNames.add( name.trim() );
                else
                    channelPairNames.add( getNameForChannelPair( name, channelNames[i + 1] ) );
            }

            channelNames = channelPairNames;

            int startBit;
            const int numBits = 2;
            const bool shouldBeSet = true;

            for ( int i = 0; i < channelNames.size(); ++i )
            {
                // Each set bit represents an audio channel
                startBit = i * 2;
                BigInteger channels;
                channels.setRange( startBit, numBits, shouldBeSet );

                m_ui->comboBox_OutputChannels->addItem( channelNames[i].toRawUTF8(), channels.toInt64() );
            }
        }
        else
        {
            m_ui->comboBox_OutputChannels->addItem( getNoDeviceString() );
            m_ui->comboBox_OutputChannels->setEnabled( false );
        }
    }
}
コード例 #8
0
ファイル: BigInteger.cpp プロジェクト: vgck/opendr2
BigInteger BigInteger::inverseModN(const BigInteger &n) const
{
	BigInteger r;

	BigNum::inverseModN(r,*this, n);

	r.debugInitStr();
    return r;
}
コード例 #9
0
ファイル: juce_linux_JackAudio.cpp プロジェクト: 0x4d52/ugen
    BigInteger getActiveOutputChannels() const
    {
        BigInteger outputBits;

        for (int i = 0; i < outputPorts.size(); i++)
            if (juce::jack_port_connected ((jack_port_t*) outputPorts [i]))
                outputBits.setBit (i);

        return outputBits;
    }
コード例 #10
0
ファイル: BigInteger.cpp プロジェクト: changm/tessa
//  q = this->divBy(divisor)  is equilvalent to:  q = this->quickDivMod(divisor,remainderResult); this = remainderResult;
BigInteger* BigInteger::divBy(const BigInteger* divisor, BigInteger* divResult)
{
    BigInteger tempInt;
    tempInt.setFromInteger(0);

    quickDivMod(divisor, &tempInt, divResult);  // this has been hard to get right.  If bugs do show up,
    //divResult = divideByReciprocalMethod(divisor,tempInt,divResult); //  try this version instead  Its slower, but less likely to be buggy
    this->copyFrom(&tempInt);
    return divResult;
}
コード例 #11
0
    const BigInteger getActiveInputChannels() const
    {
        BigInteger inputBits;

        for (int i = 0; i < inputPorts.size(); i++)
            if (JUCE_NAMESPACE::jack_port_connected ((jack_port_t*) inputPorts [i]))
                inputBits.setBit (i);

        return inputBits;
    }
コード例 #12
0
ファイル: BigInteger.cpp プロジェクト: malharDeshpande/bu-met
void
BigInteger::subtract(const BigInteger &a, const BigInteger &b)
{
  ALIASED(this == &a || this == &b, add(a, b));
  if (a.sign() == Zero) {
    _mag = b._mag;
    _sign = (b.sign() == Pos) ? Neg : (b.sign() == Zero) ? Zero : Pos;
  } else if (b.sign() == Zero) {
    *this = a;
  } else if (a.sign() != b.sign()) {
    _sign = a.sign();
    _mag.add(a._mag, b._mag);
  } else {
    switch (a._mag.compareTo(b._mag)) {
    case equal:
      _mag = 0;
      _sign = Zero;
      break;
    case greater:
      _sign = a.sign();
      _mag.subtract(a._mag, b._mag);
      break;
    case less:
      _sign = (b.sign() == Pos) ? Neg : (b.sign() == Zero) ? Zero : Pos;
      _mag.subtract(b._mag, a._mag);
      break;
    }
  }
}// subtract
コード例 #13
0
ファイル: Program.cpp プロジェクト: peterloos/Cpp_BigInteger
void Test_BigMersennePrime()
{
    BigInteger mersenne (1);
    BigInteger two (2);
    for (int i = 0; i < 11213; i ++)
        mersenne = mersenne * two;
    mersenne = mersenne - 1;

    cout << "Mersenne: " << endl << mersenne << endl;
    cout << "Number of Digits: " << mersenne.Cardinality() << endl;
}
コード例 #14
0
ファイル: 10862.cpp プロジェクト: Johniel/uva
 int compare(BigInteger &in, bool abs) {
     if(sign() != in.sign() && !abs)
         return (sign())? GREATER : LESS;
     if(size() != in.size())
         return (size() > in.size())? GREATER : LESS;
     for(int i=in.size()-1; i>=0; i--) {
         if(value[i] == in.value[i])continue;
         return (value[i] > in.value[i])? GREATER : LESS;
     }
     return EQUAL;
 }
コード例 #15
0
ファイル: bigrational.cpp プロジェクト: vadimkantorov/urfu
	BigInteger operator-(BigInteger& x)
	{
		BigInteger res;
		res.size = max(size,x.size) + 1;

		for(int i = 0; i < res.size; i++)
			res.M[i] = M[i] - x.M[i];

		res.Normalize();
		return res;
	}
コード例 #16
0
 BigInteger operator / (const BigInteger& b) const {
     assert(b > 0);  // 除数必须大于0
     BigInteger c = *this;       // 商:主要是让c.s和(*this).s的vector一样大
     BigInteger m;               // 余数:初始化为0
     for (int i = s.size()-1; i >= 0; i--) {
         m = m*BASE + s[i];
         c.s[i] = bsearch(b, m);
         m -= b*c.s[i];
     }
     return c.clean();
 }
コード例 #17
0
void YSE::SYNTH::implementationObject::addVoices(const YSE::SYNTH::samplerConfig & voice, int numVoices) {
  for (int i = 0; i < numVoices; i++) {
    synthesizer.addVoice(new SamplerVoice());
  }

  File ioFile;
  ioFile = File::getCurrentWorkingDirectory().getChildFile(juce::String(voice.file()));
  ScopedPointer<AudioFormatReader> audioreader(SOUND::Manager().getReader(ioFile));
  BigInteger allNotes;
  allNotes.setRange(voice.lowestNote(), voice.highestNote(), true);
  synthesizer.addSound(new samplerSoundWithChannel(voice.name(), *audioreader, voice.channel(), allNotes, voice.root(), voice.attackTime(), voice.releaseTime(), voice.maxLength()));
}
コード例 #18
0
ファイル: bigrational.cpp プロジェクト: vadimkantorov/urfu
	BigInteger operator*(BigInteger& x)
	{
		BigInteger res;
		res.size = size + x.size + 2;

 		for(int i = 0; i < size; i++)
			for(int j = 0; j < x.size; j++)
				res.M[i+j] += M[i]*x.M[j];

		res.Normalize();
		return res;
	}
コード例 #19
0
ファイル: 424.cpp プロジェクト: Johniel/uva
  int compare(BigInteger &in, bool abs){
    if(sign() != in.sign() && !abs)
      return (sign())? LESS : GREATER;
    if(size() != in.size())
      return (size() < in.size())? LESS : GREATER;
    for(int i=in.size()-1; i>=0; i--){
      if(in[i] == value[i])
	continue;
      return (value[i] < value[i])? LESS : GREATER;
    }
    return EQUAL;
  }
コード例 #20
0
ファイル: 10183.cpp プロジェクト: Johniel/uva
 BigInteger operator - (BigInteger &in){
   if(sign() != in.sign())
     return add(*this, in, sign());
   else if(compare(in, true) == LESS){
     // cout << toString() << " > " << in.toString() << endl;
     return sub(*this, in, sign());
   }
   else{
     //cout << toString() << " < " << in.toString() << endl;
     return sub(in, *this, !in.sign());
   }
 }
コード例 #21
0
 BigInteger operator - (const BigInteger& b) const {
     assert(b <= *this); // 减数不能大于被减数
     BigInteger c; c.s.clear();
     for (int i = 0, g = 0; ; i++) {
         if (g == 0 && i >= s.size() && i >= b.s.size()) break;
         int x = s[i] + g;
         if (i < b.s.size()) x -= b.s[i];
         if (x < 0) {g = -1; x += BASE;} else g = 0;
         c.s.push_back(x);
     }
     return c.clean();
 }
コード例 #22
0
    //==============================================================================
    static String encryptXML (const XmlElement& xml, RSAKey privateKey)
    {
        MemoryOutputStream text;
        text << xml.createDocument (StringRef(), true);

        BigInteger val;
        val.loadFromMemoryBlock (text.getMemoryBlock());

        privateKey.applyToValue (val);

        return val.toString (16);
    }
コード例 #23
0
ファイル: UVa10157.cpp プロジェクト: Chin-Z/aoapc-book
 BigInteger operator * (const BigInteger& b) const {
   BigInteger c;
   c.s.resize(s.size() + b.s.size() + 1);
   fill(c.s.begin(), c.s.end(), 0);
   for(int i = 0; i < s.size(); i++)
     for(int j = 0; j < b.s.size(); j++) {
       long long sum = (long long)s[i] * b.s[j] + c.s[i+j];
       c.s[i+j+1] += sum / BASE;
       c.s[i+j] = sum % BASE;
     }
   c.adjust();
   return c;
 }
コード例 #24
0
ファイル: UVa10157.cpp プロジェクト: Chin-Z/aoapc-book
 BigInteger operator - (const BigInteger& b) const {
   BigInteger c;
   c.s.resize(s.size());
   for(int i = 0, g = 0; i < s.size(); i++) {
     c.s[i] = s[i] - g;
     g = 0;
     int sub = (i < b.s.size() ? b.s[i] : 0);
     if(c.s[i] < sub) { g = 1; c.s[i] += BASE; }
     c.s[i] -= sub;
   }
   c.adjust();
   return c;
 }
コード例 #25
0
ファイル: UVa10303.cpp プロジェクト: Chin-Z/aoapc-book
 BigInteger divmod (int b, int& d) const {
   BigInteger c;
   c.s.clear();
   d = 0;
   for(int i = s.size()-1; i >= 0; i--) {
     long long v = (long long)d * BASE + s[i];
     c.s.push_back(v / b);
     d = v % b;
   }
   reverse(c.s.begin(), c.s.end());
   c.adjust();
   return c;
 }
コード例 #26
0
 BigInteger operator * (const BigInteger& b) const {
     int i, j; LL g;
     vector<LL> v(s.size()+b.s.size(), 0);
     BigInteger c; c.s.clear();
     for(i=0;i<s.size();i++) for(j=0;j<b.s.size();j++) v[i+j]+=LL(s[i])*b.s[j];
     for (i = 0, g = 0; ; i++) {
         if (g ==0 && i >= v.size()) break;
         LL x = v[i] + g;
         c.s.push_back(x % BASE);
         g = x / BASE;
     }
     return c.clean();
 }
コード例 #27
0
ファイル: ecc.cpp プロジェクト: im-infamou5/SPAKEclient
ECPoint ECCurve::toAffine(ECPointJacobian &p)
{
	BigInteger z = p.getZ();

	BigInteger zInv = z.invm(_p);
	BigInteger z2Inv = (zInv * zInv) % _p;
	BigInteger z3Inv = (z2Inv * zInv) % _p;

	BigInteger x = p.getX();
	BigInteger y = p.getY();

	return ECPoint((x * z2Inv) % _p, (y * z3Inv) % _p);
}
コード例 #28
0
	BigInteger operator * (const BigInteger &multiplier) const {
		BigInteger res;
		res.data.assign(data.size() + multiplier.data.size(), 0);
		res.sign = sign * multiplier.sign;
		for (size_t i = 0; i < data.size(); ++i)
			for (size_t j = 0, carry = 0; j < multiplier.data.size() || carry; ++j) {
				long long cur = res.data[i + j] + data[i] * 1LL * (j < multiplier.data.size() ? multiplier.data[j] : 0) + carry;
				res.data[i + j] = (int) (cur % base);
				carry = (size_t) (cur / base);
			}
		res.removeLeadingZeros();
		return res;
	}
コード例 #29
0
bool ElGamal::decrypt(const BigInteger &a, const BigInteger &b, BigInteger &out) const
{
    try
    {
        out = b.modMulRecip(a.modExp(x, p, recip, nb).inverseModN(p), p, recip, nb);
        return true;
    }
    catch (ArithmeticException &)
    {
    }

    return false;
}
コード例 #30
0
ファイル: program.cpp プロジェクト: dingswork/Code
// 高精度整数减法。
BigInteger operator-(const BigInteger& x, const BigInteger& y)
{
    BigInteger z;

    // 当 x 和 y 至少有一个是负数,转换为加法运算。
    if (x.sign == NEGATIVE || y.sign == NEGATIVE)
    {
        z = y;
        z.sign = -y.sign;
        return x + z;
    }

    // 都为正数,确保 x 大于 y,便于计算。
    if (x < y)
    {
        z = y - x;
        z.sign = NEGATIVE;
        return z;
    }

    // 设置符号位并预先分配存储空间。
    z.sign = POSITIVE;
    z.digits.resize(max(x.digits.size(), y.digits.size()));

    fill(z.digits.begin(), z.digits.end(), 0);

    // 逐位相减,考虑借位。
    int index = 0, borrow = 0;
    for (; index < x.digits.size(); index++)
    {
        // 获取对应位的差。
        int difference = x.digits[index] - borrow;
        difference -= index < y.digits.size() ? y.digits[index] : 0;

        // 确定是否有借位。
        borrow = 0;
        if (difference < 0)
        {
            difference += z.base;
            borrow = 1;
        }

        // 保存相应位差的结果。
        z.digits[index] = difference % z.base;
    }

    // 移除前导零。
    z.zeroJustify();

    return z;
}