Changeset 1318
- Timestamp:
- 12/20/07 19:38:54 (10 months ago)
- Location:
- trunk/src/buzelib
- Files:
-
- 14 modified
-
AnalyzerView.cpp (modified) (4 diffs)
-
AnalyzerView.h (modified) (4 diffs)
-
BuzeConfiguration.cpp (modified) (1 diff)
-
BuzeConfiguration.h (modified) (1 diff)
-
Document.h (modified) (1 diff)
-
MachineView.cpp (modified) (2 diffs)
-
MainFrm.cpp (modified) (3 diffs)
-
MainFrm.h (modified) (1 diff)
-
PatternEditor/PatternEditorControl.cpp (modified) (1 diff)
-
PatternEditor/PatternEditorInner.cpp (modified) (8 diffs)
-
PatternEditor/PatternEditorInner.h (modified) (4 diffs)
-
PatternView.cpp (modified) (3 diffs)
-
PatternView.h (modified) (1 diff)
-
resource.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/buzelib/AnalyzerView.cpp
r1312 r1318 21 21 bitmapBits = 0; 22 22 bufferScreenWidth = 0; 23 mode = 0; 23 24 setBufferSize(MAX_FFT_SIZE*2); 24 25 } … … 123 124 } 124 125 126 static float fftfunc(float x) 127 { 128 if(x == 0.0) return 0.0; 129 130 x = log10(x) * 40.0 - 40; 131 132 return x; 133 } 134 135 void AnalyzerView::drawOscilloscope() 136 { 137 int i, len; 138 RECT rect; 139 GetClientRect(&rect); 140 int _width = rect.right - rect.left; 141 int _height = rect.bottom - rect.top; 142 143 queueCritial.lock(); 144 deque<vector<int> > copyQueue = fftQueue; 145 fftQueue.clear(); 146 queueCritial.unlock(); 147 148 if (!copyQueue.empty()) { 149 vector<int>& points = copyQueue.front(); 150 151 memset(bitmapBits, 0, _height * _width * sizeof(bitmapBits[0])); 152 153 len = points.size(); 154 if(len > _width) len = _width; 155 if(len > 512) len = 512; 156 157 int y = points[0] * 100 / 32768 + 200; 158 if(y < 0) y = 0; 159 else if(y >= _height) y = _height - 1; 160 int prevy = y; 161 162 for(i = 0; i < len; i++) { 163 y = points[i] * 100 / 32768 + 200; 164 if(y < 0) y = 0; 165 else if(y >= _height) y = _height - 1; 166 167 int sy; 168 169 /* draw line: skip first pixel unless ydiff = 0 */ 170 171 if(y < prevy) { 172 prevy--; 173 174 for(int j = y; j <= prevy; j++) { 175 bitmapBits[i + j * _width] = RGB(64, 255, 64); 176 } 177 } else if(y > prevy) { 178 prevy++; 179 180 for(int j = prevy; j <= y; j++) { 181 bitmapBits[i + j * _width] = RGB(64, 255, 64); 182 } 183 } else { /* y = prevy */ 184 bitmapBits[i + y * _width] = RGB(64, 255, 64); 185 } 186 187 prevy = y; 188 } 189 } 190 191 /* draw fft */ 192 193 int pts = fft.Points() / 2 + 1; 194 float scaleHeight = (float)_height / (float)pts;///(float)fft.Points()/2; 195 double frqd = (double)pts / (double)_height; 196 197 if (!copyQueue.empty()) { 198 199 vector<int>& points = copyQueue.front(); 200 fft.Transform(points); 201 202 if(pts > _width) 203 pts = _width; 204 205 int y = fftfunc(fft.GetIntensity(0)); 206 if(y < 0) y = 0; 207 else if(y >= _height) y = _height - 1; 208 int prevy = y; 209 210 for (int i = 0; i < pts; i++) { 211 212 y = fftfunc(fft.GetIntensity(i)); 213 if(y < 0) y = 0; 214 else if(y >= _height) y = _height - 1; 215 216 int sy; 217 218 /* draw line: skip first pixel unless ydiff = 0 */ 219 220 if(y < prevy) { 221 prevy--; 222 223 for(int j = y; j <= prevy; j++) { 224 bitmapBits[i + j * _width] = RGB(64, 255, 64); 225 } 226 } else if(y > prevy) { 227 prevy++; 228 229 for(int j = prevy; j <= y; j++) { 230 bitmapBits[i + j * _width] = RGB(64, 255, 64); 231 } 232 } else { /* y = prevy */ 233 bitmapBits[i + y * _width] = RGB(64, 255, 64); 234 } 235 236 prevy = y; 237 } 238 copyQueue.pop_front(); 239 } 240 241 while (!copyQueue.empty()) { 242 vector<int>& points = copyQueue.front(); 243 fft.Transform(points); 244 245 copyQueue.pop_front(); 246 } 247 } 248 249 LRESULT AnalyzerView::OnEraseBkgnd(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { 250 return TRUE; 251 } 252 125 253 LRESULT AnalyzerView::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { 126 254 127 255 if (!background.m_hBitmap) return 0; 128 256 129 drawFft(); 257 if (mode == 0) 258 drawFft(); else 259 if (mode == 1) 260 drawOscilloscope(); 130 261 131 262 CPaintDC dc(m_hWnd); … … 143 274 } 144 275 276 LRESULT AnalyzerView::OnRButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { 277 // set up context menu that sends ID_ANALYZER_MODE_FIRST ID_ANALYZER_MODE_FIRST+1 etc 278 POINT pt = { LOWORD(lParam), HIWORD(lParam) }; 279 CMenu menu; 280 menu.CreatePopupMenu(); 281 menu.InsertMenu(-1, MF_BYPOSITION|MF_STRING|(mode==0?MF_CHECKED:0), (UINT_PTR)ID_ANALYZER_MODE_FIRST + 0, "Simple"); 282 menu.InsertMenu(-1, MF_BYPOSITION|MF_STRING|(mode==1?MF_CHECKED:0), (UINT_PTR)ID_ANALYZER_MODE_FIRST + 1, "Oscilloscope"); 283 284 ClientToScreen(&pt); 285 286 menu.TrackPopupMenu(TPM_CENTERALIGN | TPM_LEFTBUTTON, pt.x, pt.y, m_hWnd, 0); 287 288 return 0; 289 } 290 291 LRESULT AnalyzerView::OnAnalyzerSetMode(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) { 292 RECT rect; 293 GetClientRect(&rect); 294 int _width = rect.right - rect.left; 295 int _height = rect.bottom - rect.top; 296 memset(bitmapBits, 0, _height * _width * sizeof(bitmapBits[0])); 297 298 WORD type = wID - ID_ANALYZER_MODE_FIRST; 299 switch (type) { 300 case 0: 301 mode = 0; 302 break; 303 case 1: 304 mode = 1; 305 break; 306 } 307 return 0; 308 } 309 145 310 void AnalyzerView::writeBuffer(float** buffer, size_t numSamples) { 146 311 … … 166 331 } 167 332 333 -
trunk/src/buzelib/AnalyzerView.h
r1273 r1318 17 17 unsigned int* bitmapBits; 18 18 CBitmap background; 19 int mode; 19 20 20 21 public: 21 // DECLARE_WND_CLASS("WaveTableView")22 DECLARE_WND_CLASS("AnalyzerView") 22 23 // DECLARE_WND_CLASS_EX("AnalyzerView", CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS, BLACK) 23 24 … … 29 30 MESSAGE_HANDLER(WM_CLOSE, OnClose) 30 31 MESSAGE_HANDLER(WM_SETFOCUS, OnFocus) 32 MESSAGE_HANDLER(WM_RBUTTONDOWN, OnRButtonDown) 33 MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd) 34 35 COMMAND_RANGE_HANDLER(ID_ANALYZER_MODE_FIRST, ID_ANALYZER_MODE_LAST, OnAnalyzerSetMode) 31 36 END_MSG_MAP() 32 37 … … 35 40 ~AnalyzerView(void); 36 41 37 static CWndClassInfo& GetWndClassInfo() {38 static CWndClassInfo wc =39 { {40 sizeof(WNDCLASSEX), CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS, StartWindowProc,0, 0, NULL, NULL, NULL, (HBRUSH)::GetStockObject(BLACK_BRUSH),NULL,GetWndClassName(), NULL41 },42 NULL, NULL, IDC_ARROW, TRUE, 0, _T("")43 };44 return wc;45 }46 47 static LPCTSTR GetWndClassName()48 {49 return _T("AnalyzerView");50 }51 52 42 LRESULT OnSize(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); 53 43 LRESULT OnClose(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); … … 55 45 LRESULT OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); 56 46 LRESULT OnFocus(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); 47 LRESULT OnRButtonDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); 48 LRESULT OnEraseBkgnd(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); 49 LRESULT OnAnalyzerSetMode(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); 57 50 58 51 void writeBuffer(float** samples, size_t numSamples); 59 52 60 53 void drawFft(); 54 void drawOscilloscope(); 61 55 //void work(float* buffer, unsigned int numSamples); 62 56 }; -
trunk/src/buzelib/BuzeConfiguration.cpp
r1313 r1318 369 369 return atof(str.c_str()); 370 370 } 371 372 std::string CConfiguration::getNoteOffString() { 373 string s; 374 if (!getConfigString("Settings", "NoteOffString", &s)) 375 return "off"; 376 377 if (s.size() > 3) 378 s.resize(3); 379 return s; 380 } 381 382 void CConfiguration::setNoteOffString(std::string s) { 383 setConfigString("Settings", "NoteOffString", s); 384 } -
trunk/src/buzelib/BuzeConfiguration.h
r1313 r1318 68 68 double getMachineScale(); 69 69 70 void setNoteOffString(std::string s); 71 std::string getNoteOffString(); 72 70 73 }; -
trunk/src/buzelib/Document.h
r1315 r1318 55 55 56 56 UpdateTheme, 57 UpdateSettings, 57 58 58 59 UpdateClearWave, -
trunk/src/buzelib/MachineView.cpp
r1315 r1318 242 242 if (scale<MAX_MACHINE_SCALE) { 243 243 scale+=0.1; 244 _Module.configuration->setMachineScale(scale); 244 245 invalidateMachines(); 245 246 } … … 247 248 if (scale>0.3) { 248 249 scale-=0.1; 250 _Module.configuration->setMachineScale(scale); 249 251 invalidateMachines(); 250 252 } -
trunk/src/buzelib/MainFrm.cpp
r1317 r1318 1604 1604 } 1605 1605 1606 if (player->getSoloMachine() != 0) 1607 document->setMachineSolo(player->getSoloMachine(), FALSE); 1608 1606 1609 return 0; 1607 1610 } … … 2846 2849 { "PE Text Note", RGB(0x20, 0x20, 0x80) }, 2847 2850 { "PE Text Shade", RGB(0x68, 0x68, 0x68) }, 2851 { "PE Text Margin", RGB(0x7F, 0x73, 0x53) }, 2852 { "PE Text Note Off", RGB(0xdd, 0x33, 0xdd) }, 2848 2853 { "SA Amp BG", RGB(0x70, 0x80, 0x90) }, 2849 2854 { "SA Amp Line", RGB(0x00, 0xC8, 0x00) }, … … 2918 2923 } 2919 2924 2925 void CMainFrame::setDefaultOverrideColor(std::string dest, std::string src) { 2926 map<string, COLORREF>::iterator i; 2927 2928 if (theme.find(dest) != theme.end()) 2929 return; 2930 2931 i = theme.find(src); 2932 2933 if (i != theme.end()) 2934 theme.insert(pair<string, COLORREF>(dest, i->second)); 2935 } 2936 2920 2937 void CMainFrame::setTheme(std::string themeName) { 2921 2938 2922 2939 theme.clear(); 2923 2940 2924 for (unsigned int i = 0; i< defaultThemeCount; i++) {2925 theme.insert(pair<string, COLORREF>(defaultTheme[i].name, defaultTheme[i].color));2926 }2927 2941 2928 2942 FileReader reader; 2929 2943 string fileName = "Themes/" + themeName + ".col"; 2930 if (!reader.open(fileName.c_str())) goto finishTheme; 2931 2932 while (!reader.eof()) { 2933 std::string line=trim(reader.readLine()); 2934 if (line.length()==0) continue; 2935 if (line.at(0)=='#') continue; 2936 2937 size_t lt = line.find_first_of('\t'); 2938 if (lt == string::npos) continue; 2939 2940 string name = trim(line.substr(0, lt)); 2941 string colorstr = trim(line.substr(lt+1)); 2942 if (colorstr.length() != 6) continue; 2943 2944 COLORREF color = RGB( 2945 intFromHex(colorstr.substr(0, 2)), 2946 intFromHex(colorstr.substr(2, 2)), 2947 intFromHex(colorstr.substr(4, 2)) 2948 ); 2949 theme[name] = color;//.insert(pair<string, COLORREF>(name, color)); 2950 } 2951 2952 reader.close(); 2953 2954 finishTheme: 2944 if (reader.open(fileName.c_str())) { 2945 2946 while (!reader.eof()) { 2947 std::string line=trim(reader.readLine()); 2948 if (line.length()==0) continue; 2949 if (line.at(0)=='#') continue; 2950 2951 size_t lt = line.find_first_of('\t'); 2952 if (lt == string::npos) continue; 2953 2954 string name = trim(line.substr(0, lt)); 2955 string colorstr = trim(line.substr(lt+1)); 2956 if (colorstr.length() != 6) continue; 2957 2958 COLORREF color = RGB( 2959 intFromHex(colorstr.substr(0, 2)), 2960 intFromHex(colorstr.substr(2, 2)), 2961 intFromHex(colorstr.substr(4, 2)) 2962 ); 2963 theme[name] = color; 2964 } 2965 reader.close(); 2966 } 2967 2968 #if 0 // Uncomment this so that legacy buzz themes look their best with buze's new theme values 2969 2970 // Theme-based defaults 2971 2972 setDefaultOverrideColor("PE Text Note", "PE Text"); 2973 setDefaultOverrideColor("PE Text Note Off", "PE Text"); 2974 setDefaultOverrideColor("PE Text Shade", "PE Text"); 2975 setDefaultOverrideColor("PE Text Margin", "PE Text Note"); 2976 2977 #endif 2978 2979 // Defaults 2980 2981 for (unsigned int i = 0; i< defaultThemeCount; i++) { 2982 if (theme.find(defaultTheme[i].name) == theme.end()) 2983 theme.insert(pair<string, COLORREF>(defaultTheme[i].name, defaultTheme[i].color)); 2984 } 2985 2955 2986 document->updateAllViews(0, UpdateTheme); 2956 2987 -
trunk/src/buzelib/MainFrm.h
r1315 r1318 562 562 std::string getThemeName(size_t index); 563 563 void setTheme(std::string theme); 564 void setDefaultOverrideColor(std::string dest, std::string src); 564 565 COLORREF getThemeColor(std::string name); 565 566 -
trunk/src/buzelib/PatternEditor/PatternEditorControl.cpp
r1315 r1318 33 33 screenDC.SelectFont(editor.track_font); 34 34 screenDC.SetBkColor(bgcolor); 35 screenDC.SetTextColor(editor.colors[PE_Text Note]);35 screenDC.SetTextColor(editor.colors[PE_TextMargin]); 36 36 37 37 // render row numbers -
trunk/src/buzelib/PatternEditor/PatternEditorInner.cpp
r1303 r1318 23 23 } 24 24 25 std::string noteFromInt(unsigned char i ) {26 if (i == 255) return "off";25 std::string noteFromInt(unsigned char i, std::string noteOffStr) { 26 if (i == 255) return noteOffStr; 27 27 char* notes[]={"..", "C-", "C#", "D-", "D#", "E-", "F-", "F#", "G-", "G#", "A-", "A#", "B-", "..", "..", "..", ".." }; 28 28 char pc[16]; … … 65 65 step = 1; 66 66 last_play_pos = -1; 67 noteOffStr = "off"; 68 stickySelection = false; 67 69 68 70 SetThemeColor(PE_BG, RGB(0xDA, 0xD6, 0xC9)); … … 151 153 if (v == columns[j].novalue) 152 154 dc.SetTextColor(colors[PE_TextShade]); else 153 if (columns[j].type == pattern_column_type_note) 154 dc.SetTextColor(colors[PE_TextNote]); else 155 dc.SetTextColor(colors[PE_TextValue]); 155 if (columns[j].type == pattern_column_type_note) { 156 if (v == 255) // This represents a note off 157 dc.SetTextColor(colors[PE_TextNoteOff]); 158 else 159 dc.SetTextColor(colors[PE_TextNote]); 160 } 161 else dc.SetTextColor(colors[PE_TextValue]); 156 162 157 163 int dest_x = columns[j].unit * font_size.cx; … … 663 669 switch (type) { 664 670 case pattern_column_type_note: 665 return v!=novalue?noteFromInt(v ):"...";671 return v!=novalue?noteFromInt(v, noteOffStr):"..."; 666 672 case pattern_column_type_byte: 667 673 return v!=novalue?hexFromInt(v, 2, '0'):".."; … … 919 925 if (affectsel) { 920 926 if (IsShiftDown()) { 927 if (stickySelection == true) { 928 if (cursor_columns[last_cursor.x].column < select_start.x || 929 cursor_columns[last_cursor.x].column > select_end.x || 930 last_cursor.y < select_start.y || 931 last_cursor.y > select_end.y) 932 { 933 InvalidateSelection(); 934 SelectRange(-1, -1, -1, -1); 935 } 936 } 921 937 if (select_first.x == -1) { 922 938 // begin selection … … 928 944 } else { 929 945 if (select_first.x != -1) { 930 SelectRange(-1, -1, -1, -1); 946 if (stickySelection == false) 947 SelectRange(-1, -1, -1, -1); 931 948 } 932 949 } … … 1072 1089 if (!m_hWnd) return ; 1073 1090 1091 InvalidateSelection(&rcPrevSel); 1092 } 1093 1094 void CPatternEditorInner::InvalidateSelection(RECT *rcPrevSel) { 1074 1095 RECT rcSel; 1096 1097 if(!rcPrevSel) 1098 rcPrevSel = &rcSel; 1099 1075 1100 if (!GetSelectionRectScreen(&rcSel)) 1076 1101 rcSel.left = -1; 1077 1102 1078 if (rcSel.left != -1 && rcPrevSel .left != -1) {1079 UnionRect(&rcSel, &rcSel, &rcPrevSel);1103 if (rcSel.left != -1 && rcPrevSel->left != -1) { 1104 UnionRect(&rcSel, &rcSel, rcPrevSel); 1080 1105 } else 1081 1106 if (rcSel.left == -1) { 1082 rcSel = rcPrevSel;1107 rcSel = *rcPrevSel; 1083 1108 } 1084 1109 … … 1112 1137 void CPatternEditorInner::SetThemeColor(theme_index index, COLORREF color) { 1113 1138 colors[index] = color; 1139 } 1140 1141 void CPatternEditorInner::SetNoteOffStr(std::string s) { 1142 noteOffStr = s; 1143 1144 } 1145 1146 void CPatternEditorInner::SetStickySelection(bool setting) { 1147 stickySelection = setting; 1114 1148 } 1115 1149 -
trunk/src/buzelib/PatternEditor/PatternEditorInner.h
r1263 r1318 74 74 PE_TextNote = 6, 75 75 PE_TextValue = 7, 76 PE_TextNoteOff = 8, 77 PE_TextMargin = 9, 78 76 79 }; 77 80 78 81 class CPatternEditorInner : public CWindowImpl<CPatternEditorInner> { 79 82 public: 80 COLORREF colors[ 8];83 COLORREF colors[10]; 81 84 SIZE font_size, pattern_size; 82 85 RECT rcClient; … … 88 91 CBitmap pattern_bitmap; 89 92 CFont track_font; 93 std::string noteOffStr; 94 bool stickySelection; 90 95 91 96 int rows, total_rows; … … 152 157 void SetFont(HFONT hFont, bool bRedraw = 1); 153 158 void SetThemeColor(theme_index index, COLORREF color); 159 void SetNoteOffStr(std::string s); 160 void SetStickySelection(bool setting); 154 161 void MoveCursor(int x, int y, bool affectsel); 155 162 void ScrollTo(POINT pt); // scroll to position pt … … 159 166 bool GetRangeRectScreen(int from_col, int from_row, int to_col, int to_row, RECT* rc); 160 167 bool GetSelectionRect(RECT* rc); 168 void InvalidateSelection(RECT *rcPrevSel = NULL); 161 169 void SetHighlightRows(int verydarkrow, int darkrow); 162 170 void SelectRange(int from_col, int from_row, int to_col, int to_row); -
trunk/src/buzelib/PatternView.cpp
r1314 r1318 224 224 setPatternEditorFont(); 225 225 226 bindSettings(); 226 227 bindTheme(); 227 228 bindPatternEditor(); … … 574 575 break; 575 576 } 577 case UpdateSettings: 578 bindSettings(); 579 break;
