Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

AudioSegment.qml 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. // tonalisa - software to look at overtone-structures
  2. // Copyright (C) 2016 Dominik Schmidt-Philipp
  3. //
  4. // This program is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. //
  17. import QtQuick 2.3
  18. import QtQuick.Dialogs 1.2
  19. import QtQuick.Controls 1.2
  20. import art.freakaria.ton 1.0
  21. Item {
  22. id:root
  23. property alias audio:activeAudioFile
  24. AudioFile {
  25. id:activeAudioFile
  26. }
  27. Peaks {
  28. id: peakCalculator
  29. fftData: activeAudioFile.spectrum
  30. sampleRate:activeAudioFile.sampleRate
  31. windowIndex:activeAudioFile.windowIndex
  32. windowSize:activeAudioFile.windowSize
  33. onPeaksChanged: {
  34. buffer.spectrumF0 = peaks
  35. var tmp=[]
  36. for(var i=0;i<peaks.length;i++){
  37. if(i%2)
  38. tmp.push(peaks[i])
  39. else
  40. tmp.push(peaks[i]/peaks[0])
  41. }
  42. buffer.spectrumR1 = tmp
  43. }
  44. }
  45. FileDialog {
  46. id:fileDialog
  47. title:"choose a sound file"
  48. //folder: shortcuts.home
  49. onAccepted: {
  50. activeAudioFile.path = fileDialog.fileUrl
  51. }
  52. onRejected: {
  53. // console.log("cancelled")
  54. }
  55. }
  56. Waveform {
  57. id:audioDisplay
  58. height:70;width:parent.width
  59. }
  60. Column {
  61. y:audioDisplay.height
  62. spacing: 2
  63. Row {
  64. Button {
  65. id: openFileButton
  66. focus:true
  67. text: "open"
  68. onClicked: { fileDialog.open() }
  69. }
  70. }
  71. Row {
  72. ComboBox {
  73. id:transformSizeSelect
  74. width:70;
  75. currentIndex:3;
  76. property var sizes:[512,1024,2048,4096,8192,16384,32768]
  77. onCurrentIndexChanged: {
  78. activeAudioFile.npts = sizes[currentIndex]
  79. windowSizeInput.update_position();
  80. activeAudioFile.calculateFFT()
  81. }
  82. model:sizes
  83. }
  84. ComboBox {
  85. id:windowSelect
  86. width: 150
  87. model: ["Rectangular", "Hann", "Welch", "Parzen", "Bartlett", "Hamming", "Blackman2", "Blackman3", "Blackman4", "Exponential", "Riemann", "Kaiser", "Cauchy", "Poisson", "Gaussian", "Tukey", "Dolph-Chebyshev", "Hann-Poisson", "Connes", "Samaraki", "Ultraspherical", "Bartlett-Hann", "Bohman", "Flat-top", "Blackman5", "Blackman6", "Blackman7", "Blackman8", "Blackman9", "Blackman10", "Rife-Vincent2", "Rife-Vincent3", "Rife-Vincent4", "MLT Sine", "Papoulis", "DPSS (Slepian)", "Sinc"]
  88. currentIndex:1;
  89. onCurrentIndexChanged: {
  90. activeAudioFile.windowIndex = currentIndex
  91. activeAudioFile.calculateFFT()
  92. }
  93. }
  94. Slider {
  95. y:14
  96. id:windowSizeInput
  97. value:0
  98. onValueChanged: {
  99. activeAudioFile.windowSize = value * activeAudioFile.npts;//* 40000 + 100;
  100. }
  101. function update_position(){
  102. value = activeAudioFile.windowSize / activeAudioFile.npts;
  103. console.log(value)
  104. }
  105. }
  106. Text {
  107. property real samples: activeAudioFile.windowSize;
  108. text:"window Size: "+ samples +" samples"
  109. }
  110. } // end Transform options row
  111. Row {
  112. id:peakFinding
  113. Text {
  114. property real thresh: Math.floor(peakCalculator.threshold)
  115. text: "Threshold: "+thresh+"dB"
  116. }
  117. Slider {
  118. y:14
  119. id:peakThresholdcontrol
  120. value:0
  121. onValueChanged: {
  122. peakCalculator.threshold = -value*100
  123. }
  124. }
  125. } // end Peakfinding Row
  126. }
  127. }