comparison layer/SpectrogramLayer.cpp @ 21:3a506d25d95a

* Add command history class, and basic undo/redo menus. No actual commands to undo/redo yet. Selecting the placeholders sometimes seems to cause a crash, so this looks a little uncertain so far. * Add Rename Layer * Remove models from playback when their layers are removed (and ref counts hit zero) * Don't hang around waiting so much when there's work to be done in the audio buffer fill thread * Put more sensible names on layers generated from transforms * Add basic editing to time-value layer like existing editing in time-instants layer, and make both of them snap to the appropriate resolution during drag
author Chris Cannam
date Mon, 30 Jan 2006 17:51:56 +0000
parents 1deb5f87a18c
children 6b794a2af3d9
comparison
equal deleted inserted replaced
20:1deb5f87a18c 21:3a506d25d95a
1101 } 1101 }
1102 1102
1103 bool 1103 bool
1104 SpectrogramLayer::getXBinRange(int x, float &s0, float &s1) const 1104 SpectrogramLayer::getXBinRange(int x, float &s0, float &s1) const
1105 { 1105 {
1106 // long startFrame; 1106 size_t modelStart = m_model->getStartFrame();
1107 // int zoomLevel; 1107 size_t modelEnd = m_model->getEndFrame();
1108 size_t modelStart;
1109 size_t modelEnd;
1110
1111 // startFrame = m_view->getStartFrame();
1112 // zoomLevel = m_view->getZoomLevel();
1113 modelStart = m_model->getStartFrame();
1114 modelEnd = m_model->getEndFrame();
1115 1108
1116 // Each pixel column covers an exact range of sample frames: 1109 // Each pixel column covers an exact range of sample frames:
1117 int f0 = getFrameForX(x) - modelStart; 1110 int f0 = getFrameForX(x) - modelStart;
1118 int f1 = getFrameForX(x + 1) - modelStart - 1; 1111 int f1 = getFrameForX(x + 1) - modelStart - 1;
1119 1112
1120 /*
1121 int f0 = startFrame + x * zoomLevel - modelStart;
1122 int f1 = f0 + zoomLevel - 1;
1123 */
1124 if (f1 < int(modelStart) || f0 > int(modelEnd)) return false; 1113 if (f1 < int(modelStart) || f0 > int(modelEnd)) return false;
1125 1114
1126 // And that range may be drawn from a possibly non-integral 1115 // And that range may be drawn from a possibly non-integral
1127 // range of spectrogram windows: 1116 // range of spectrogram windows:
1128 1117
1129 size_t windowIncrement = getWindowIncrement(); 1118 size_t windowIncrement = getWindowIncrement();
1130
1131 s0 = float(f0) / windowIncrement; 1119 s0 = float(f0) / windowIncrement;
1132 s1 = float(f1) / windowIncrement; 1120 s1 = float(f1) / windowIncrement;
1133 1121
1134 return true; 1122 return true;
1135 } 1123 }