Exemplo n.º 1
0
void MyShip::ply_sf(QString &add) {
	if (!SettingData::sfMut) {
		QSoundEffect *sf = new QSoundEffect();
		sf->setSource(QUrl::fromLocalFile(add));
		sf->setVolume(SettingData::sfVol / 100.0);
		sf->play();
	}
}
Exemplo n.º 2
0
/**
 * @brief NoteEditScene::changeTimes 再生時にスクロールが行われたときに呼ばれる
 * @param millisec
 */
void NoteEditScene::changeTimes(qint64 millisec)
{

   for(QList<Note*>::iterator it = noteList.begin();it!=noteList.end();it++)
   {
       Note* n = *it;
       qint64 s = n->startTime();
       qint64 e = n->endTime();
       if((s >= previousTime && s < millisec) ||
               (e >= previousTime && e < millisec))
       {
            QSoundEffect *snd = new QSoundEffect();
            snd->setSource(QUrl::fromLocalFile(":/new/sound/perfect.wav"));
            snd->play();
            QObject::connect(snd, &QSoundEffect::playingChanged, [this](){
                delete sender();
            });



//            QMediaPlayer *player = new QMediaPlayer;
//            player->setMedia(QUrl::fromLocalFile("/Users/tetsushi2/Desktop/perfect.wav"));
//            QObject::connect(player, SIGNAL(stateChanged(QMediaPlayer::State)), this, SLOT(destoryPlayer(QMediaPlayer::State)));
//            playerList.append(player);
//            player->play();
//            qDebug()<<player->state();
//            if(player->state() == QMediaPlayer::State::StoppedState)
//            {
//                player->play();
//            }
//            else if(player->state() == QMediaPlayer::PlayingState)
//            {

//                player->stop();
//                player->setPosition(0);
//                player->play();
//            }
           break;
       }
   }

    previousTime = millisec;
}
Exemplo n.º 3
0
/*
 * Hack -- Make a (relevant?) sound
 */
void sound(int val)
{
    QSoundEffect effect;

    QString sound_file;
    sound_file.clear();

    // Play just once
    effect.setLoopCount(1);

    qreal this_volume = (ui_get_sound_volume() / 100);

    if (!this_volume) return;

    effect.setVolume(this_volume);

    switch (val)
    {
        case SOUND_HIT:
        {
            int which_sound = randint0(7);

            if (which_sound == 0)       sound_file = "attack_hit.wav";
            else if (which_sound == 1)  sound_file = "attack_hit1.wav";
            else if (which_sound == 2)  sound_file = "attack_hit2.wav";
            else if (which_sound == 3)  sound_file = "attack_hit3.wav";
            else if (which_sound == 4)  sound_file = "attack_hit4.wav";
            else if (which_sound == 5)  sound_file = "attack_hit5.wav";
            else if (which_sound == 6)  sound_file = "attack_hit6.wav";
            break;
        }
        //  No Sound File
        default: return;
    }

    // No sound file
    if (!sound_file.length()) return;

    effect.setSource(QUrl::fromLocalFile(QString("%1/%2") .arg(npp_dir_sound.path()) .arg(sound_file)));

    effect.play();
}
Exemplo n.º 4
0
void MainWindow::initSoundEffects(const QString pathToSounds)
{
    //QSound::play("./sounds/facedetected.wav");
   // bla.setLoops(-1);
   // bla.play();


    QSoundEffect* facedetectedFX = new QSoundEffect(this);
    QSoundEffect* countdownFX = new QSoundEffect(this);
    QSoundEffect* alarmFX = new QSoundEffect(this);
    QSoundEffect* noAnswerFX = new QSoundEffect(this);
    QSoundEffect* welcomeFX = new QSoundEffect(this);

    facedetectedFX->setSource(QUrl::fromLocalFile(pathToSounds + "facedetected.wav"));
    facedetectedFX->setLoopCount(1);

    countdownFX->setSource(QUrl::fromLocalFile(pathToSounds + "countdown.wav"));
    countdownFX->setLoopCount(1);

    alarmFX->setSource(QUrl::fromLocalFile(pathToSounds + "alarm.wav"));
    alarmFX->setLoopCount(QSoundEffect::Infinite);

    noAnswerFX->setSource(QUrl::fromLocalFile(pathToSounds + "noanswer.wav"));
    noAnswerFX->setLoopCount(1);

    welcomeFX->setSource(QUrl::fromLocalFile(pathToSounds + "welcome.wav"));
    welcomeFX->setLoopCount(1);



    m_soundEffects.insert("FaceDetected",facedetectedFX);
    m_soundEffects.insert("AlarmCountDown",countdownFX);
    m_soundEffects.insert("AlarmSound",alarmFX);
    m_soundEffects.insert("Welcome",welcomeFX);
    m_soundEffects.insert("NoAnswer",noAnswerFX);
}