Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | mainwin.py: handle divide-by-zero if/when fex line is zero length spectogram.py: initial eraser functionality added |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | master |
Files: | files | file ages | folders |
SHA3-256: |
5db78221eacc80aa687f7baf7f000bb1 |
User & Date: | jmcclure 2017-08-18 10:50:21 |
Context
2017-08-26
| ||
23:51 | Converted config to yaml; packaging clean up; nearing beta release check-in: 93665ca85c user: jmcclure tags: trunk, master | |
2017-08-18
| ||
10:50 | mainwin.py: handle divide-by-zero if/when fex line is zero length spectogram.py: initial eraser functionality added check-in: 5db78221ea user: jmcclure tags: trunk, master | |
2017-08-17
| ||
22:44 | Initial commit of fexqt check-in: 2dab5527e8 user: jmcclure tags: trunk, master | |
Changes
Changes to fexqt/mainwin.py.
︙ | ︙ | |||
27 28 29 30 31 32 33 | QTimer.singleShot(20,self.next_spectrogram) # Todo handle drag & drop of sound files def update_status_fex(self, pex, tex): self.pex = pex self.tex = tex | > | > > | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | QTimer.singleShot(20,self.next_spectrogram) # Todo handle drag & drop of sound files def update_status_fex(self, pex, tex): self.pex = pex self.tex = tex try: self.fex = pex / tex except ZeroDivisionError: self.fex = 0.0 def update_status_text(self, x, y): self.status_text.setText("FEX: %.3f %0.3fs %0.1fKHz" %(self.fex,x,y)) def init_body(self, config): self.body = QWidget() self.body.setBackgroundRole(QPalette.AlternateBase) |
︙ | ︙ |
Changes to fexqt/spectrogram.py.
︙ | ︙ | |||
46 47 48 49 50 51 52 | self.time = t h, w = self.imgdata.shape self.image = QImage(self.imgdata.tobytes(), w, h, w, QImage.Format_Grayscale8) if self.conf.invert: self.image.invertPixels() self.fit() | | > | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | self.time = t h, w = self.imgdata.shape self.image = QImage(self.imgdata.tobytes(), w, h, w, QImage.Format_Grayscale8) if self.conf.invert: self.image.invertPixels() self.fit() self.eraser = self.create_eraser(10, 200) self.eraser.maxheight = 200 self.cursorX = self.create_cursor(1, self.height() * 4) self.cursorY = self.create_cursor(self.width() * 4, 1) self.cursorX.hide() self.cursorY.hide() self.eraser.hide() self.show() |
︙ | ︙ | |||
142 143 144 145 146 147 148 | self.resize(self.height() * asp, self.height()) def resizeEvent(self, e): self.sx = self.width() / self.image.width() self.sy = self.height() / self.image.height() def mousePressEvent(self, e): | > > > > > > > > | | | < < > > > > > > > > > > > > > > > > > > | > > > > > > > > | 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | self.resize(self.height() * asp, self.height()) def resizeEvent(self, e): self.sx = self.width() / self.image.width() self.sy = self.height() / self.image.height() def mousePressEvent(self, e): if self.cursorX.visible(): pass elif self.eraser.visible(): # TODO create undo/backup of imgdata & initial erase pass elif e.button() == Qt.MiddleButton: self.fit() else: self.__pos = self.pos() self.__size = self.size() self.__epos = self.mapToParent(e.pos()) def mouseMoveEvent(self, e): # TODO refactor this rats nest y = e.pos().y() if y < self.eraser.maxheight / 2.0: fixed = y * 2.0 elif y > self.height() - self.eraser.maxheight / 2.0: fixed = (self.height() - y) * 2.0 else: fixed = self.eraser.maxheight self.eraser.setFixedHeight(int(clip(fixed,0,self.eraser.maxheight))) x = e.pos().x() - self.eraser.width() / 2.0 y = e.pos().y() - self.eraser.height() / 2.0 self.eraser.move(x, y) x = e.pos().x() y = e.pos().y() self.cursorX.move(x, 0) self.cursorY.move(0, y) s = self.imgdata.shape x = clip(int(s[1] * e.pos().x() / self.width()), 0, self.time.size) y = clip(int(s[0] * e.pos().y() / self.height()), 0, self.freq.size) self.mouseOver.emit(self.time[x], self.time[y]) if e.buttons() and self.cursorX.isVisible(): self.mouseCursorEvent(e) elif e.buttons() and self.eraser.isVisible(): self.mouseEraseEvent(e) elif e.buttons(): self.mouseNormalEvent(e) def mouseCursorEvent(self, e): pass def mapToImgdata(self, x, y): s = self.imgdata.shape x *= s[1] / self.width() y *= s[0] / self.height() x = int(clip(x, 0, s[1])) y = int(clip(y, 0, s[0])) return x, y def mouseEraseEvent(self, e): w = self.eraser.width() h = self.eraser.height() x = e.pos().x() - w / 2.0 y = e.pos().y() - h / 2.0 x1, y1 = self.mapToImgdata(x, y) x2, y2 = self.mapToImgdata(x + w, y + h) self.imgdata[y1:y2,x1:x2] = 255.0 self.update(x, 0, w, self.height()) def mouseNormalEvent(self, e): if e.buttons() == Qt.LeftButton: diff = self.mapToParent(e.pos()) - self.__epos + self.__pos self.move(diff) elif e.buttons() == Qt.RightButton: diff = self.mapToParent(e.pos()) - self.__epos w = self.__size.width() + diff.x() h = self.__size.height() + diff.y() self.resize(w, h) def mouseReleaseEvent(self, e): self.cursorX.resize(1, self.height() * 4) self.cursorY.resize(self.width() * 4, 1) self.update(self.contentsRect()) |