【Project】情緒評定

來源:互聯網
上載者:User

前兩天幫心理系的寫的一個小程式,灰常灰常簡單。

大致內容是通過一些情緒學習之後,評定之後聲音的情緒反應。軟體的需求也比較簡單:

  1. 給定三種類型的masker音頻,亂序之後播放給被試;
  2. 被試聽到聲音之後,根據情緒感受,對情緒效價和情緒喚起打分;
  3. 打分之後自動播放下一個聲音;
  4. 最後統計三種類型的平均分;
大致效果如下:介面用QT寫的,聲音播放用的QT Phonon內建的
//建立媒體對象media_object = new Phonon::MediaObject(this);Phonon::AudioOutput *audio_output = new Phonon::AudioOutput(Phonon::MusicCategory, this);Phonon::createPath(media_object, audio_output);//繫結來源和接收器

一個定時重新整理介面的函數:可以實現自動播放下一個聲音

timer =new QTimer(this);  connect( timer, SIGNAL(timeout()), this, SLOT(NextSource()) );   timer->start(1000);  //每20毫秒重新整理一次介面

重新整理時判斷使用者操作:

void SAM::NextSource(){if(selected_a==1&&selected_b==1){selected_a=0;selected_b=0;//some ui codes hereplayed_counter++;if(played_counter>=sources.size()){QMessageBox msgBox;msgBox.setText(QString::fromLocal8Bit("測試結束\n謝謝您的參與!"));msgBox.setStyleSheet("font: 48pt \"幼圓\";background-color: rgb(0,0,0));color: rgb(255, 255, 255);");msgBox.exec();qApp->quit();std::ofstream fout("out.txt");fout<<"Log:"<<std::endl;fout<<"masker\ta\tb"<<std::endl;float masker1_suma=0,masker1_sumb=0;float masker2_suma=0,masker2_sumb=0;float masker3_suma=0,masker3_sumb=0;int masker1_counter=0,masker2_counter=0,masker3_counter=0;for(int i=0;i<sources.size();i++){fout<<source_maskers[i]<<"\t"<<source_a[i]<<"\t"<<source_b[i]<<std::endl;if(source_maskers[i]==1){masker1_suma+=source_a[i];masker1_sumb+=source_b[i];++masker1_counter;}else if(source_maskers[i]==2){masker2_suma+=source_a[i];masker2_sumb+=source_b[i];++masker2_counter;}else if(source_maskers[i]==3){masker3_suma+=source_a[i];masker3_sumb+=source_b[i];++masker3_counter;}}fout<<"\nAverage:"<<std::endl;fout<<"masker\ta\tb"<<std::endl;masker1_suma=(float)masker1_suma/masker1_counter;masker1_sumb=(float)masker1_sumb/masker1_counter;masker2_suma=(float)masker2_suma/masker2_counter;masker2_sumb=(float)masker2_sumb/masker2_counter;masker3_suma=(float)masker3_suma/masker3_counter;masker3_sumb=(float)masker3_sumb/masker3_counter;fout<<"1\t"<<masker1_suma<<"\t"<<masker1_sumb<<std::endl;fout<<"2\t"<<masker2_suma<<"\t"<<masker2_sumb<<std::endl;fout<<"3\t"<<masker3_suma<<"\t"<<masker3_sumb<<std::endl;}else{int played_index=source_orders[played_counter];media_object->setCurrentSource(sources.at(played_index));media_object->play();}}}

還有一個亂序的函數:

void SAM::RandVector(){int source_size=sources.size();for(int i=0;i<source_size;i++){bool if_order=false;while(!if_order){int tmp_order=rand()%source_size;if(source_orders[tmp_order]==-1){source_orders[tmp_order]=i;if_order=true;}}}for(int i=0;i<source_size;i++){int source_index=source_orders[i];Phonon::MediaSource current_source=sources[source_index];const std::string source_name=current_source.fileName().toStdString();if(source_name.find("masker1")<source_name.size()){source_maskers.push_back(1);}else if(source_name.find("masker2")<source_name.size()){source_maskers.push_back(2);}else if(source_name.find("masker3")<source_name.size()){source_maskers.push_back(3);}}}

工程:http://download.csdn.net/detail/xiaowei_cqu/5370789代碼:http://www.pudn.com/downloads542/sourcecode/multimedia/audio/detail2241547.html(轉載請註明作者和出處:http://blog.csdn.net/xiaowei_cqu 未經允許請勿用於商業用途)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.