Ticket #6107: soundrecoderLocalization.patch
File soundrecoderLocalization.patch, 53.3 KB (added by , 14 years ago) |
---|
-
src/apps/soundrecorder/FileUtils.cpp
1 /****************************************************************************** *1 /****************************************************************************** 2 2 / 3 3 / File: FileUtils.cpp 4 4 / … … 6 6 / 7 7 / Copyright 1998-1999, Be Incorporated, All Rights Reserved 8 8 / 9 ****************************************************************************** */9 ******************************************************************************/ 10 10 #include "FileUtils.h" 11 11 12 12 #include <new> … … 102 102 } 103 103 // NOTE: Attributes of size 0 are perfectly valid! 104 104 while (read >= 0) { 105 ssize_t written = dst.WriteAttr(attrName, info.type, offset, buffer,106 read);105 ssize_t written = dst.WriteAttr(attrName, info.type, offset, 106 buffer, read); 107 107 if (written != read) { 108 108 fprintf(stderr, "Error writing attribute '%s'\n", attrName); 109 109 if (written < 0) -
src/apps/soundrecorder/RecorderWindow.h
8 8 #ifndef RECORDERWINDOW_H 9 9 #define RECORDERWINDOW_H 10 10 11 #include <Catalog.h> 11 12 #include <Directory.h> 12 13 #include <Entry.h> 13 14 #include <File.h> 14 15 #include <FilePanel.h> 16 #include <Locale.h> 15 17 #include <MediaFile.h> 16 18 #include <MediaNode.h> 17 19 #include <MediaTrack.h> … … 167 169 168 170 void RefsReceived(BMessage *msg); 169 171 void CopyTarget(BMessage *msg); 172 BCatalog fAppCatalog; 170 173 }; 171 174 172 175 #endif /* RECORDERWINDOW_H */ -
src/apps/soundrecorder/ScopeView.cpp
121 121 int64 framesCount = fMediaTrack->CountFrames() / SAMPLES_COUNT; 122 122 if (framesCount <= 0) 123 123 return; 124 T samples[fPlayFormat.u.raw_audio.buffer_size / (fPlayFormat.u.raw_audio.format 124 T samples[fPlayFormat.u.raw_audio.buffer_size 125 / (fPlayFormat.u.raw_audio.format 125 126 & media_raw_audio_format::B_AUDIO_SIZE_MASK)]; 126 127 int64 frames = 0; 127 128 U sum = 0; … … 149 150 break; 150 151 151 152 if (sumCount >= framesCount) { 152 //TRACE("computing block %ld, sumCount %ld\n", previewIndex, sumCount); 153 // TRACE("computing block %ld, sumCount %ld\n", previewIndex, 154 // sumCount); 153 155 fPreview[previewIndex] = (int32)(sum 154 156 / fPlayFormat.u.raw_audio.channel_count / framesCount); 155 157 if (previewMax < fPreview[previewIndex]) … … 164 166 if (previewMax <= 0) 165 167 return; 166 168 for (int i = 0; i < SAMPLES_COUNT; i++) 167 fPreview[i] = (int32)(fPreview[i] * 1.0 / previewMax * middle + middle); 169 fPreview[i] = (int32)(fPreview[i] * 1.0 / previewMax 170 * middle + middle); 168 171 } 169 172 170 173 -
src/apps/soundrecorder/SoundConsumer.cpp
1 /****************************************************************************** *1 /****************************************************************************** 2 2 / 3 3 / File: SoundConsumer.cpp 4 4 / … … 6 6 / 7 7 / Copyright 1998-1999, Be Incorporated, All Rights Reserved 8 8 / 9 ****************************************************************************** */9 ******************************************************************************/ 10 10 #include "SoundConsumer.h" 11 11 12 12 #include <new> -
src/apps/soundrecorder/TrackSlider.cpp
2 2 * Copyright 2005, Jérôme Duval. All rights reserved. 3 3 * Distributed under the terms of the MIT License. 4 4 * 5 * Inspired by SoundCapture from Be newsletter (Media Kit Basics: Consumers and Producers) 5 * Inspired by SoundCapture from Be newsletter (Media Kit Basics: Consumers 6 * and Producers) 6 7 */ 7 8 8 9 #include <stdio.h> … … 12 13 #include "TrackSlider.h" 13 14 #include "icon_button.h" 14 15 15 TrackSlider::TrackSlider(BRect rect, const char *title, BMessage *msg, uint32 resizeFlags) 16 : BControl(rect, "slider", NULL, msg, resizeFlags, B_WILL_DRAW | B_FRAME_EVENTS), 17 fLeftTime(0), fRightTime(1000000), fMainTime(0), fTotalTime(1000000), 18 fLeftTracking(false), fRightTracking(false), fMainTracking(false), 19 fBitmap(NULL), fBitmapView(NULL) 16 TrackSlider::TrackSlider(BRect rect, const char *title, BMessage *msg, 17 uint32 resizeFlags) 18 : 19 BControl(rect, "slider", NULL, msg, resizeFlags, B_WILL_DRAW 20 | B_FRAME_EVENTS), 21 fLeftTime(0), 22 fRightTime(1000000), 23 fMainTime(0), 24 fTotalTime(1000000), 25 fLeftTracking(false), 26 fRightTracking(false), 27 fMainTracking(false), 28 fBitmap(NULL), 29 fBitmapView(NULL) 20 30 { 21 31 fFont.SetSize(8.0); 22 32 fFont.SetFlags(B_DISABLE_ANTIALIASING); … … 74 84 fBitmapView->fRightX = fBitmapView->fRight; 75 85 fBitmapView->fPositionX = 15; 76 86 } else { 77 fBitmapView->fLeftX = 14 + (fBitmapView->fRight - 15) * ((double)fLeftTime / fTotalTime); 78 fBitmapView->fRightX = 15 + (fBitmapView->fRight - 16) * ((double)fRightTime / fTotalTime); 79 fBitmapView->fPositionX = 15 + (fBitmapView->fRight - 14) * ((double)fMainTime / fTotalTime); 87 fBitmapView->fLeftX = 14 + (fBitmapView->fRight - 15) 88 * ((double)fLeftTime / fTotalTime); 89 fBitmapView->fRightX = 15 + (fBitmapView->fRight - 16) 90 * ((double)fRightTime / fTotalTime); 91 fBitmapView->fPositionX = 15 + (fBitmapView->fRight - 14) 92 * ((double)fMainTime / fTotalTime); 80 93 } 81 94 } 82 95 … … 132 145 133 146 BeginLineArray(4); 134 147 if (!isTracking) { 135 AddLine(BPoint(counterX-halfwidth-3,SLIDER_BASE+1), BPoint(counterX+halfwidth+3,SLIDER_BASE+1), gray); 136 AddLine(BPoint(counterX+halfwidth+4,SLIDER_BASE+1), BPoint(counterX+halfwidth+4,SLIDER_BASE-8), gray); 137 AddLine(BPoint(counterX-halfwidth-4,SLIDER_BASE+1), BPoint(counterX-halfwidth-4,SLIDER_BASE-9), white); 138 AddLine(BPoint(counterX-halfwidth-3,SLIDER_BASE-9), BPoint(counterX+halfwidth+4,SLIDER_BASE-9), white); 148 AddLine(BPoint(counterX-halfwidth-3,SLIDER_BASE+1), 149 BPoint(counterX+halfwidth+3,SLIDER_BASE+1), gray); 150 AddLine(BPoint(counterX+halfwidth+4,SLIDER_BASE+1), 151 BPoint(counterX+halfwidth+4,SLIDER_BASE-8), gray); 152 AddLine(BPoint(counterX-halfwidth-4,SLIDER_BASE+1), 153 BPoint(counterX-halfwidth-4,SLIDER_BASE-9), white); 154 AddLine(BPoint(counterX-halfwidth-3,SLIDER_BASE-9), 155 BPoint(counterX+halfwidth+4,SLIDER_BASE-9), white); 139 156 SetHighColor(216,216,216); 140 157 } else { 141 AddLine(BPoint(counterX-halfwidth-3,SLIDER_BASE+1), BPoint(counterX+halfwidth+3,SLIDER_BASE+1), blue); 142 AddLine(BPoint(counterX+halfwidth+4,SLIDER_BASE+1), BPoint(counterX+halfwidth+4,SLIDER_BASE-9), blue2); 143 AddLine(BPoint(counterX-halfwidth-4,SLIDER_BASE+1), BPoint(counterX-halfwidth-4,SLIDER_BASE-9), blue2); 144 AddLine(BPoint(counterX-halfwidth-3,SLIDER_BASE-9), BPoint(counterX+halfwidth+3,SLIDER_BASE-9), blue2); 158 AddLine(BPoint(counterX-halfwidth-3,SLIDER_BASE+1), 159 BPoint(counterX+halfwidth+3,SLIDER_BASE+1), blue); 160 AddLine(BPoint(counterX+halfwidth+4,SLIDER_BASE+1), 161 BPoint(counterX+halfwidth+4,SLIDER_BASE-9), blue2); 162 AddLine(BPoint(counterX-halfwidth-4,SLIDER_BASE+1), 163 BPoint(counterX-halfwidth-4,SLIDER_BASE-9), blue2); 164 AddLine(BPoint(counterX-halfwidth-3,SLIDER_BASE-9), 165 BPoint(counterX+halfwidth+3,SLIDER_BASE-9), blue2); 145 166 SetHighColor(48,48,241); 146 167 } 147 168 EndLineArray(); 148 FillRect(BRect(counterX-halfwidth-3,SLIDER_BASE-8,counterX+halfwidth+3,SLIDER_BASE)); 169 FillRect(BRect(counterX-halfwidth-3,SLIDER_BASE-8,counterX+halfwidth+3, 170 SLIDER_BASE)); 149 171 150 172 #ifdef __HAIKU__ 151 173 SetDrawingMode(B_OP_OVER); … … 174 196 rgb_color white = {255,255,255}; 175 197 176 198 BeginLineArray(30); 177 AddLine(BPoint(position,SLIDER_BASE+7), BPoint(position-4,SLIDER_BASE+3), black); 178 AddLine(BPoint(position-4,SLIDER_BASE+3), BPoint(position-4,SLIDER_BASE+1), black); 179 AddLine(BPoint(position-4,SLIDER_BASE+1), BPoint(position+4,SLIDER_BASE+1), black); 180 AddLine(BPoint(position+4,SLIDER_BASE+1), BPoint(position+4,SLIDER_BASE+3), black); 181 AddLine(BPoint(position+4,SLIDER_BASE+3), BPoint(position,SLIDER_BASE+7), black); 199 AddLine(BPoint(position,SLIDER_BASE+7), BPoint(position-4,SLIDER_BASE+3), 200 black); 201 AddLine(BPoint(position-4,SLIDER_BASE+3), BPoint(position-4,SLIDER_BASE+1), 202 black); 203 AddLine(BPoint(position-4,SLIDER_BASE+1), BPoint(position+4,SLIDER_BASE+1), 204 black); 205 AddLine(BPoint(position+4,SLIDER_BASE+1), BPoint(position+4,SLIDER_BASE+3), 206 black); 207 AddLine(BPoint(position+4,SLIDER_BASE+3), BPoint(position,SLIDER_BASE+7), 208 black); 182 209 183 210 184 AddLine(BPoint(position-3,SLIDER_BASE+2), BPoint(position+3,SLIDER_BASE+2), rose); 185 AddLine(BPoint(position-3,SLIDER_BASE+3), BPoint(position-1,SLIDER_BASE+5), rose); 211 AddLine(BPoint(position-3,SLIDER_BASE+2), BPoint(position+3,SLIDER_BASE+2), 212 rose); 213 AddLine(BPoint(position-3,SLIDER_BASE+3), BPoint(position-1,SLIDER_BASE+5), 214 rose); 186 215 187 AddLine(BPoint(position-2,SLIDER_BASE+3), BPoint(position+2,SLIDER_BASE+3), red); 188 AddLine(BPoint(position-1,SLIDER_BASE+4), BPoint(position+1,SLIDER_BASE+4), red); 189 AddLine(BPoint(position,SLIDER_BASE+5), BPoint(position,SLIDER_BASE+5), red); 216 AddLine(BPoint(position-2,SLIDER_BASE+3), BPoint(position+2,SLIDER_BASE+3), 217 red); 218 AddLine(BPoint(position-1,SLIDER_BASE+4), BPoint(position+1,SLIDER_BASE+4), 219 red); 220 AddLine(BPoint(position,SLIDER_BASE+5), BPoint(position,SLIDER_BASE+5), 221 red); 190 222 191 AddLine(BPoint(position,SLIDER_BASE+6), BPoint(position+3,SLIDER_BASE+3), bordeau); 223 AddLine(BPoint(position,SLIDER_BASE+6), BPoint(position+3,SLIDER_BASE+3), 224 bordeau); 192 225 193 AddLine(BPoint(position,SLIDER_BASE+12), BPoint(position-4,SLIDER_BASE+16), black); 194 AddLine(BPoint(position-4,SLIDER_BASE+16), BPoint(position-4,SLIDER_BASE+17), black); 195 AddLine(BPoint(position-4,SLIDER_BASE+17), BPoint(position+4,SLIDER_BASE+17), black); 196 AddLine(BPoint(position+4,SLIDER_BASE+17), BPoint(position+4,SLIDER_BASE+16), black); 197 AddLine(BPoint(position+4,SLIDER_BASE+16), BPoint(position,SLIDER_BASE+12), black); 198 AddLine(BPoint(position-4,SLIDER_BASE+18), BPoint(position+4,SLIDER_BASE+18), white); 226 AddLine(BPoint(position,SLIDER_BASE+12), BPoint(position-4,SLIDER_BASE+16), 227 black); 228 AddLine(BPoint(position-4,SLIDER_BASE+16), BPoint(position-4, 229 SLIDER_BASE+17), black); 230 AddLine(BPoint(position-4,SLIDER_BASE+17), BPoint(position+4, 231 SLIDER_BASE+17), black); 232 AddLine(BPoint(position+4,SLIDER_BASE+17), BPoint(position+4, 233 SLIDER_BASE+16), black); 234 AddLine(BPoint(position+4,SLIDER_BASE+16), BPoint(position,SLIDER_BASE+12), 235 black); 236 AddLine(BPoint(position-4,SLIDER_BASE+18), BPoint(position+4, 237 SLIDER_BASE+18), white); 199 238 200 AddLine(BPoint(position-3,SLIDER_BASE+16), BPoint(position,SLIDER_BASE+13), rose); 239 AddLine(BPoint(position-3,SLIDER_BASE+16), BPoint(position,SLIDER_BASE+13), 240 rose); 201 241 202 AddLine(BPoint(position-2,SLIDER_BASE+16), BPoint(position+2,SLIDER_BASE+16), red); 203 AddLine(BPoint(position-1,SLIDER_BASE+15), BPoint(position+1,SLIDER_BASE+15), red); 204 AddLine(BPoint(position,SLIDER_BASE+14), BPoint(position,SLIDER_BASE+14), red); 242 AddLine(BPoint(position-2,SLIDER_BASE+16), BPoint(position+2, 243 SLIDER_BASE+16), red); 244 AddLine(BPoint(position-1,SLIDER_BASE+15), BPoint(position+1, 245 SLIDER_BASE+15), red); 246 AddLine(BPoint(position,SLIDER_BASE+14), BPoint(position, 247 SLIDER_BASE+14), red); 205 248 206 AddLine(BPoint(position+1,SLIDER_BASE+14), BPoint(position+3,SLIDER_BASE+16), bordeau); 249 AddLine(BPoint(position+1,SLIDER_BASE+14), BPoint(position+3, 250 SLIDER_BASE+16), bordeau); 207 251 208 252 EndLineArray(); 209 253 } … … 237 281 238 282 _UpdatePosition(point); 239 283 SetTracking(true); 240 SetMouseEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY | B_LOCK_WINDOW_FOCUS); 284 SetMouseEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY 285 | B_LOCK_WINDOW_FOCUS); 241 286 } 242 287 243 288 … … 262 307 void 263 308 TrackSlider::_UpdatePosition(BPoint point) 264 309 { 265 BRect leftRect(fBitmapView->fLeftX-9, SLIDER_BASE+3, fBitmapView->fLeftX, SLIDER_BASE+16); 266 BRect rightRect(fBitmapView->fRightX, SLIDER_BASE+3, fBitmapView->fRightX+9, SLIDER_BASE+16); 310 BRect leftRect(fBitmapView->fLeftX-9, SLIDER_BASE+3, fBitmapView->fLeftX, 311 SLIDER_BASE+16); 312 BRect rightRect(fBitmapView->fRightX, SLIDER_BASE+3, 313 fBitmapView->fRightX+9, SLIDER_BASE+16); 267 314 268 if (!(fRightTracking || fMainTracking) && (fLeftTracking || ((point.x < fBitmapView->fPositionX-4) && leftRect.Contains(point)))) { 315 if (!(fRightTracking || fMainTracking) && (fLeftTracking 316 || ((point.x < fBitmapView->fPositionX-4) && leftRect.Contains(point)))) { 269 317 if (!IsTracking()) 270 318 fBitmapView->fLastX = point.x - fBitmapView->fLeftX; 271 fBitmapView->fLeftX = MIN(MAX(point.x - fBitmapView->fLastX, 15), fBitmapView->fRight); 272 fLeftTime = (bigtime_t)(MAX(MIN((fBitmapView->fLeftX - 15) / (fBitmapView->fRight - 14),1), 0) * fTotalTime); 319 fBitmapView->fLeftX = MIN(MAX(point.x - fBitmapView->fLastX, 15), 320 fBitmapView->fRight); 321 fLeftTime = (bigtime_t)(MAX(MIN((fBitmapView->fLeftX - 15) 322 / (fBitmapView->fRight - 14),1), 0) * fTotalTime); 273 323 fLeftTracking = true; 274 324 275 325 BMessage msg = *Message(); … … 290 340 _RenderBitmap(); 291 341 292 342 //printf("fLeftPos : %Ld\n", fLeftTime); 293 } else if (!fMainTracking && (fRightTracking || ((point.x > fBitmapView->fPositionX+4) && rightRect.Contains(point)))) { 343 } else if (!fMainTracking && (fRightTracking 344 || ((point.x > fBitmapView->fPositionX+4) 345 && rightRect.Contains(point)))) { 294 346 if (!IsTracking()) 295 347 fBitmapView->fLastX = point.x - fBitmapView->fRightX; 296 fBitmapView->fRightX = MIN(MAX(point.x - fBitmapView->fLastX, 15), fBitmapView->fRight); 297 fRightTime = (bigtime_t)(MAX(MIN((fBitmapView->fRightX - 15) / (fBitmapView->fRight - 14),1), 0) * fTotalTime); 348 fBitmapView->fRightX = MIN(MAX(point.x - fBitmapView->fLastX, 15), 349 fBitmapView->fRight); 350 fRightTime = (bigtime_t)(MAX(MIN((fBitmapView->fRightX - 15) 351 / (fBitmapView->fRight - 14),1), 0) * fTotalTime); 298 352 fRightTracking = true; 299 353 300 354 BMessage msg = *Message(); … … 317 371 //printf("fRightPos : %Ld\n", fRightTime); 318 372 } else { 319 373 fBitmapView->fPositionX = MIN(MAX(point.x, 15), fBitmapView->fRight); 320 fMainTime = (bigtime_t)(MAX(MIN((fBitmapView->fPositionX - 15) / (fBitmapView->fRight - 14),1), 0) * fTotalTime); 374 fMainTime = (bigtime_t)(MAX(MIN((fBitmapView->fPositionX - 15) 375 / (fBitmapView->fRight - 14),1), 0) * fTotalTime); 321 376 fMainTracking = true; 322 377 323 378 BMessage msg = *Message(); … … 353 408 uint32 seconds = timestamp / 1000000LL; 354 409 timestamp -= seconds * 1000000LL; 355 410 uint32 centiseconds = timestamp / 10000LL; 356 sprintf(string, "%02ld:%02ld:%02ld:%02ld", hours, minutes, seconds, centiseconds);357 411 sprintf(string, "%02ld:%02ld:%02ld:%02ld", hours, minutes, seconds, 412 centiseconds); 358 413 } 359 414 360 415 … … 362 417 TrackSlider::SetMainTime(bigtime_t timestamp, bool reset) 363 418 { 364 419 fMainTime = timestamp; 365 fBitmapView->fPositionX = 15 + (fBitmapView->fRight - 14) * ((double)fMainTime / fTotalTime); 420 fBitmapView->fPositionX = 15 + (fBitmapView->fRight - 14) 421 * ((double)fMainTime / fTotalTime); 366 422 if (reset) { 367 423 fRightTime = fTotalTime; 368 424 fLeftTime = 0; 369 fBitmapView->fLeftX = 14 + (fBitmapView->fRight - 15) * ((double)fLeftTime / fTotalTime); 370 fBitmapView->fRightX = 15 + (fBitmapView->fRight - 16) * ((double)fRightTime / fTotalTime); 425 fBitmapView->fLeftX = 14 + (fBitmapView->fRight - 15) 426 * ((double)fLeftTime / fTotalTime); 427 fBitmapView->fRightX = 15 + (fBitmapView->fRight - 16) 428 * ((double)fRightTime / fTotalTime); 371 429 _RenderBitmap(); 372 430 } 373 431 Invalidate(); … … 382 440 fRightTime = fTotalTime; 383 441 fLeftTime = 0; 384 442 } 385 fBitmapView->fPositionX = 15 + (fBitmapView->fRight - 14) * ((double)fMainTime / fTotalTime); 386 fBitmapView->fLeftX = 14 + (fBitmapView->fRight - 15) * ((double)fLeftTime / fTotalTime); 387 fBitmapView->fRightX = 15 + (fBitmapView->fRight - 16) * ((double)fRightTime / fTotalTime); 443 fBitmapView->fPositionX = 15 + (fBitmapView->fRight - 14) 444 * ((double)fMainTime / fTotalTime); 445 fBitmapView->fLeftX = 14 + (fBitmapView->fRight - 15) 446 * ((double)fLeftTime / fTotalTime); 447 fBitmapView->fRightX = 15 + (fBitmapView->fRight - 16) 448 * ((double)fRightTime / fTotalTime); 388 449 _RenderBitmap(); 389 450 Invalidate(); 390 451 } … … 394 455 TrackSlider::ResetMainTime() 395 456 { 396 457 fMainTime = fLeftTime; 397 fBitmapView->fPositionX = 15 + (fBitmapView->fRight - 14) * ((double)fMainTime / fTotalTime); 458 fBitmapView->fPositionX = 15 + (fBitmapView->fRight - 14) 459 * ((double)fMainTime / fTotalTime); 398 460 Invalidate(); 399 461 } 400 462 … … 403 465 TrackSlider::FrameResized(float width, float height) 404 466 { 405 467 fBitmapView->fRight = Bounds().right - kLeftRightTrackSliderWidth; 406 fBitmapView->fPositionX = 15 + (fBitmapView->fRight - 14) * ((double)fMainTime / fTotalTime); 468 fBitmapView->fPositionX = 15 + (fBitmapView->fRight - 14) 469 * ((double)fMainTime / fTotalTime); 407 470 _InitBitmap(); 408 fBitmapView->fLeftX = 14 + (fBitmapView->fRight - 15) * ((double)fLeftTime / fTotalTime); 409 fBitmapView->fRightX = 15 + (fBitmapView->fRight - 16) * ((double)fRightTime / fTotalTime); 471 fBitmapView->fLeftX = 14 + (fBitmapView->fRight - 15) 472 * ((double)fLeftTime / fTotalTime); 473 fBitmapView->fRightX = 15 + (fBitmapView->fRight - 16) 474 * ((double)fRightTime / fTotalTime); 410 475 _RenderBitmap(); 411 476 Invalidate(); 412 477 } … … 416 481 : BView(frame, name, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW), 417 482 leftBitmap(BRect(BPoint(0,0), kLeftRightTrackSliderSize), B_CMAP8), 418 483 rightBitmap(BRect(BPoint(0,0), kLeftRightTrackSliderSize), B_CMAP8), 419 leftThumbBitmap(BRect(0, 0, kLeftRightThumbWidth - 1, kLeftRightThumbHeight - 1), B_CMAP8), 420 rightThumbBitmap(BRect(0, 0, kLeftRightThumbWidth - 1, kLeftRightThumbHeight - 1), B_CMAP8) 484 leftThumbBitmap(BRect(0, 0, kLeftRightThumbWidth - 1, 485 kLeftRightThumbHeight - 1), B_CMAP8), 486 rightThumbBitmap(BRect(0, 0, kLeftRightThumbWidth - 1, 487 kLeftRightThumbHeight - 1), B_CMAP8) 421 488 { 422 leftBitmap.SetBits(kLeftTrackSliderBits, kLeftRightTrackSliderWidth * kLeftRightTrackSliderHeight, 0, B_CMAP8); 423 rightBitmap.SetBits(kRightTrackSliderBits, kLeftRightTrackSliderWidth * kLeftRightTrackSliderHeight, 0, B_CMAP8); 424 leftThumbBitmap.SetBits(kLeftThumbBits, kLeftRightThumbWidth * kLeftRightThumbHeight, 0, B_CMAP8); 425 rightThumbBitmap.SetBits(kRightThumbBits, kLeftRightThumbWidth * kLeftRightThumbHeight, 0, B_CMAP8); 489 leftBitmap.SetBits(kLeftTrackSliderBits, 490 kLeftRightTrackSliderWidth * kLeftRightTrackSliderHeight, 0, B_CMAP8); 491 rightBitmap.SetBits(kRightTrackSliderBits, 492 kLeftRightTrackSliderWidth * kLeftRightTrackSliderHeight, 0, B_CMAP8); 493 leftThumbBitmap.SetBits(kLeftThumbBits, 494 kLeftRightThumbWidth * kLeftRightThumbHeight, 0, B_CMAP8); 495 rightThumbBitmap.SetBits(kRightThumbBits, 496 kLeftRightThumbWidth * kLeftRightThumbHeight, 0, B_CMAP8); 426 497 } 427 498 428 499 … … 451 522 SetLowColor(HighColor()); 452 523 453 524 BPoint leftPoint(5, SLIDER_BASE + 1); 454 DrawBitmapAsync(&leftBitmap, BRect(BPoint(0, 0), kLeftRightTrackSliderSize - BPoint(5, 0)), 525 DrawBitmapAsync(&leftBitmap, BRect(BPoint(0, 0), 526 kLeftRightTrackSliderSize - BPoint(5, 0)), 455 527 BRect(leftPoint, leftPoint + kLeftRightTrackSliderSize - BPoint(5, 0))); 456 528 BPoint rightPoint(fRight + 1, SLIDER_BASE + 1); 457 529 DrawBitmapAsync(&rightBitmap, BRect(BPoint(5, 0), kLeftRightTrackSliderSize), … … 461 533 FillRect(BRect(11, SLIDER_BASE + 3, fLeftX - 9, SLIDER_BASE + 16)); 462 534 FillRect(BRect(fRightX + 9, SLIDER_BASE + 3, fRight, SLIDER_BASE + 16)); 463 535 if (fLeftX > 19) { 464 StrokeLine(BPoint(fLeftX - 9, SLIDER_BASE + 3), BPoint(fLeftX - 6, SLIDER_BASE + 3)); 465 StrokeLine(BPoint(fLeftX - 9, SLIDER_BASE + 4), BPoint(fLeftX - 7, SLIDER_BASE + 4)); 466 StrokeLine(BPoint(fLeftX - 9, SLIDER_BASE + 5), BPoint(fLeftX - 8, SLIDER_BASE + 5)); 467 StrokeLine(BPoint(fLeftX - 9, SLIDER_BASE + 16), BPoint(fLeftX - 6, SLIDER_BASE + 16)); 468 StrokeLine(BPoint(fLeftX - 9, SLIDER_BASE + 15), BPoint(fLeftX - 7, SLIDER_BASE + 15)); 469 StrokeLine(BPoint(fLeftX - 9, SLIDER_BASE + 14), BPoint(fLeftX - 8, SLIDER_BASE + 14)); 536 StrokeLine(BPoint(fLeftX - 9, SLIDER_BASE + 3), BPoint(fLeftX - 6, 537 SLIDER_BASE + 3)); 538 StrokeLine(BPoint(fLeftX - 9, SLIDER_BASE + 4), BPoint(fLeftX - 7, 539 SLIDER_BASE + 4)); 540 StrokeLine(BPoint(fLeftX - 9, SLIDER_BASE + 5), BPoint(fLeftX - 8, 541 SLIDER_BASE + 5)); 542 StrokeLine(BPoint(fLeftX - 9, SLIDER_BASE + 16), BPoint(fLeftX - 6, 543 SLIDER_BASE + 16)); 544 StrokeLine(BPoint(fLeftX - 9, SLIDER_BASE + 15), BPoint(fLeftX - 7, 545 SLIDER_BASE + 15)); 546 StrokeLine(BPoint(fLeftX - 9, SLIDER_BASE + 14), BPoint(fLeftX - 8, 547 SLIDER_BASE + 14)); 470 548 } 471 549 if (fRightX < fRight - 5) { 472 StrokeLine(BPoint(fRightX + 5, SLIDER_BASE + 3), BPoint(fRightX + 8, SLIDER_BASE + 3)); 473 StrokeLine(BPoint(fRightX + 7, SLIDER_BASE + 4), BPoint(fRightX + 8, SLIDER_BASE + 4)); 474 StrokeLine(BPoint(fRightX + 8, SLIDER_BASE + 5), BPoint(fRightX + 8, SLIDER_BASE + 6)); 475 StrokeLine(BPoint(fRightX + 8, SLIDER_BASE + 13), BPoint(fRightX + 8, SLIDER_BASE + 14)); 476 StrokeLine(BPoint(fRightX + 5, SLIDER_BASE + 16), BPoint(fRightX + 8, SLIDER_BASE + 16)); 477 StrokeLine(BPoint(fRightX + 7, SLIDER_BASE + 15), BPoint(fRightX + 8, SLIDER_BASE + 15)); 550 StrokeLine(BPoint(fRightX + 5, SLIDER_BASE + 3), BPoint(fRightX + 8, 551 SLIDER_BASE + 3)); 552 StrokeLine(BPoint(fRightX + 7, SLIDER_BASE + 4), BPoint(fRightX + 8, 553 SLIDER_BASE + 4)); 554 StrokeLine(BPoint(fRightX + 8, SLIDER_BASE + 5), BPoint(fRightX + 8, 555 SLIDER_BASE + 6)); 556 StrokeLine(BPoint(fRightX + 8, SLIDER_BASE + 13), BPoint(fRightX + 8, 557 SLIDER_BASE + 14)); 558 StrokeLine(BPoint(fRightX + 5, SLIDER_BASE + 16), BPoint(fRightX + 8, 559 SLIDER_BASE + 16)); 560 StrokeLine(BPoint(fRightX + 7, SLIDER_BASE + 15), BPoint(fRightX + 8, 561 SLIDER_BASE + 15)); 478 562 } 479 563 SetHighColor(144, 186, 136); 480 564 FillRect(BRect(fLeftX + 1, SLIDER_BASE + 3, fRightX, SLIDER_BASE + 4)); … … 524 608 SetLowColor(HighColor()); 525 609 526 610 BPoint leftThumbPoint(fLeftX - 8, SLIDER_BASE + 3); 527 DrawBitmapAsync(&leftThumbBitmap, BRect(BPoint(0, 0), kLeftRightThumbSize - BPoint(7, 0)), 528 BRect(leftThumbPoint, leftThumbPoint + kLeftRightThumbSize - BPoint(7, 0))); 611 DrawBitmapAsync(&leftThumbBitmap, BRect(BPoint(0, 0), 612 kLeftRightThumbSize - BPoint(7, 0)), 613 BRect(leftThumbPoint, leftThumbPoint 614 + kLeftRightThumbSize - BPoint(7, 0))); 529 615 530 616 BPoint rightThumbPoint(fRightX, SLIDER_BASE + 3); 531 DrawBitmapAsync(&rightThumbBitmap, BRect(BPoint(6, 0), kLeftRightThumbSize), 532 BRect(rightThumbPoint, rightThumbPoint + kLeftRightThumbSize-BPoint(6, 0))); 617 DrawBitmapAsync(&rightThumbBitmap, BRect(BPoint(6, 0), 618 kLeftRightThumbSize), 619 BRect(rightThumbPoint, rightThumbPoint 620 + kLeftRightThumbSize-BPoint(6, 0))); 533 621 534 622 Sync(); 535 623 } -
src/apps/soundrecorder/SoundUtils.cpp
1 /****************************************************************************** *1 /****************************************************************************** 2 2 / 3 3 / File: SoundUtils.cpp 4 4 / … … 6 6 / 7 7 / Copyright 1998-1999, Be Incorporated, All Rights Reserved 8 8 / 9 ****************************************************************************** */9 ******************************************************************************/ 10 10 11 11 #include <math.h> 12 12 #include "SoundUtils.h" … … 58 58 // Figuring out duration is easy. We take extra precaution to 59 59 // not divide by zero or return irrelevant results. 60 60 bigtime_t duration = 0; 61 if (format.buffer_size > 0 && format.frame_rate > 0 && bytes_per_frame(format) > 0) { 61 if (format.buffer_size > 0 && format.frame_rate > 0 62 && bytes_per_frame(format) > 0) { 62 63 // In these kinds of calculations, it's always useful to double-check 63 64 // the unit conversions. (Anyone remember high school physics?) 64 65 // bytes/(bytes/frame) / frames/sec 65 66 // = frames * sec/frames 66 67 // = secs which is what we want. 67 duration = s_to_us((format.buffer_size / bytes_per_frame(format)) / format.frame_rate); 68 duration = s_to_us((format.buffer_size / bytes_per_frame(format)) 69 / format.frame_rate); 68 70 } 69 71 return duration; 70 72 } … … 87 89 const media_raw_audio_format & format, bigtime_t duration) 88 90 { 89 91 // Double-checking those unit conversions again: 90 // secs * ( (frames/sec) / (frames/buffer) ) = secs * (buffers/sec) = buffers 92 // secs * ( (frames/sec) / (frames/buffer) ) = secs * (buffers/sec) 93 // = buffers 91 94 int buffers = 0; 92 95 if (frames_per_buffer(format) > 0) { 93 buffers = (int) ceil(us_to_s(duration)*(format.frame_rate/frames_per_buffer(format))); 96 buffers = (int) ceil(us_to_s(duration) 97 *(format.frame_rate/frames_per_buffer(format))); 94 98 } 95 99 return buffers; 96 100 } -
src/apps/soundrecorder/VolumeSlider.cpp
2 2 * Copyright 2005, Jérôme Duval. All rights reserved. 3 3 * Distributed under the terms of the MIT License. 4 4 * 5 * Inspired by SoundCapture from Be newsletter (Media Kit Basics: Consumers and Producers) 5 * Inspired by SoundCapture from Be newsletter (Media Kit Basics: Consumers 6 * and Producers) 6 7 */ 7 8 8 9 #include <stdio.h> … … 14 15 #define RATIO 2.0f 15 16 16 17 VolumeSlider::VolumeSlider(BRect rect, const char *title, uint32 resizeFlags) 17 : BControl(rect, "slider", NULL, new BMessage(VOLUME_CHANGED), resizeFlags, B_WILL_DRAW), 18 fLeftBitmap(BRect(0, 0, kLeftVolumeWidth - 1, kLeftVolumeHeight - 1), B_CMAP8), 19 fRightBitmap(BRect(0, 0, kRightVolumeWidth - 1, kRightVolumeHeight - 1), B_CMAP8), 18 : BControl(rect, "slider", NULL, new BMessage(VOLUME_CHANGED), 19 resizeFlags, B_WILL_DRAW), 20 fLeftBitmap(BRect(0, 0, kLeftVolumeWidth - 1, kLeftVolumeHeight - 1), 21 B_CMAP8), 22 fRightBitmap(BRect(0, 0, kRightVolumeWidth - 1, kRightVolumeHeight - 1), 23 B_CMAP8), 20 24 fButtonBitmap(BRect(0, 0, kThumbWidth - 1, kThumbHeight - 1), B_CMAP8), 21 25 fSoundPlayer(NULL) 22 26 { 23 fLeftBitmap.SetBits(kLeftVolumeBits, kLeftVolumeWidth * kLeftVolumeHeight, 0, B_CMAP8); 24 fRightBitmap.SetBits(kRightVolumeBits, kRightVolumeWidth * kRightVolumeHeight, 0, B_CMAP8); 27 fLeftBitmap.SetBits(kLeftVolumeBits, kLeftVolumeWidth * kLeftVolumeHeight, 28 0, B_CMAP8); 29 fRightBitmap.SetBits(kRightVolumeBits, kRightVolumeWidth * kRightVolumeHeight, 30 0, B_CMAP8); 25 31 fButtonBitmap.SetBits(kThumbBits, kThumbWidth * kThumbHeight, 0, B_CMAP8); 26 32 27 33 fRight = Bounds().right - 15; … … 53 59 DrawBitmapAsync(&fLeftBitmap, BPoint(5,1)); 54 60 DrawBitmapAsync(&fRightBitmap, BPoint(fRight + 1,1)); 55 61 56 float position = 11 + (fRight - 11) * (fSoundPlayer ? fSoundPlayer->Volume() / RATIO : 0); 62 float position = 11 + (fRight - 11) * (fSoundPlayer 63 ? fSoundPlayer->Volume() / RATIO : 0); 57 64 SetHighColor(102,152,102); 58 65 FillRect(BRect(11,3,position,4)); 59 66 SetHighColor(152,203,152); … … 153 160 154 161 SpeakerView::SpeakerView(BRect rect, uint32 resizeFlags) 155 162 : BBox(rect, "speaker", resizeFlags, B_WILL_DRAW, B_NO_BORDER), 156 fSpeakerBitmap(BRect(0, 0, kSpeakerIconBitmapWidth - 1, kSpeakerIconBitmapHeight - 1), B_CMAP8) 163 fSpeakerBitmap(BRect(0, 0, kSpeakerIconBitmapWidth - 1, 164 kSpeakerIconBitmapHeight - 1), B_CMAP8) 157 165 { 158 fSpeakerBitmap.SetBits(kSpeakerIconBits, kSpeakerIconBitmapWidth * kSpeakerIconBitmapHeight, 0, B_CMAP8); 166 fSpeakerBitmap.SetBits(kSpeakerIconBits, kSpeakerIconBitmapWidth 167 * kSpeakerIconBitmapHeight, 0, B_CMAP8); 159 168 } 160 169 161 170 -
src/apps/soundrecorder/DrawingTidbits.cpp
2 2 * Copyright 2005, Jérôme Duval. All rights reserved. 3 3 * Distributed under the terms of the MIT License. 4 4 * 5 * Inspired by SoundCapture from Be newsletter (Media Kit Basics: Consumers and Producers) 5 * Inspired by SoundCapture from Be newsletter (Media Kit Basics: Consumers 6 * and Producers) 6 7 */ 7 8 8 9 #include <Bitmap.h> … … 48 49 void 49 50 ReplaceColor(BBitmap *bitmap, rgb_color from, rgb_color to) 50 51 { 51 ASSERT(bitmap->ColorSpace() == B_CMAP8); // other color spaces not implemented yet 52 ASSERT(bitmap->ColorSpace() == B_CMAP8); 53 // other color spaces not implemented yet 52 54 53 55 BScreen screen(B_MAIN_SCREEN_ID); 54 56 uint32 fromIndex = screen.IndexForColor(from); … … 64 66 void 65 67 ReplaceTransparentColor(BBitmap *bitmap, rgb_color with) 66 68 { 67 ASSERT(bitmap->ColorSpace() == B_CMAP8); // other color spaces not implemented yet 69 ASSERT(bitmap->ColorSpace() == B_CMAP8); 70 // other color spaces not implemented yet 68 71 69 72 BScreen screen(B_MAIN_SCREEN_ID); 70 73 uint8 withIndex = screen.IndexForColor(with); -
src/apps/soundrecorder/SoundListView.cpp
2 2 * Copyright 2005, Jérôme Duval. All rights reserved. 3 3 * Distributed under the terms of the MIT License. 4 4 * 5 * Inspired by SoundCapture from Be newsletter (Media Kit Basics: Consumers and Producers) 5 * Inspired by SoundCapture from Be newsletter (Media Kit Basics: Consumers 6 * and Producers) 6 7 */ 8 #include <Catalog.h> 7 9 #include <Entry.h> 10 #include <Locale.h> 8 11 9 12 #include "SoundListView.h" 10 13 11 14 15 #undef B_TRANSLATE_CONTEXT 16 #define B_TRANSLATE_CONTEXT "SoundListView" 17 18 12 19 SoundListView::SoundListView( 13 20 const BRect & area, 14 21 const char * name, … … 36 43 SetFont(&font); 37 44 font_height height; 38 45 font.GetHeight(&height); 39 float width = font.StringWidth( "Drop files here");46 float width = font.StringWidth(B_TRANSLATE("Drop files here")); 40 47 41 48 BPoint pt; 42 49 pt.x = (Bounds().Width() - width) / 2; 43 50 pt.y = (Bounds().Height() + height.ascent + height.descent)/ 2; 44 DrawString( "Drop files here", pt);51 DrawString(B_TRANSLATE("Drop files here"), pt); 45 52 } 46 53 BListView::Draw(updateRect); 47 54 } -
src/apps/soundrecorder/VUView.cpp
76 76 void 77 77 VUView::_Run() 78 78 { 79 fThreadId = spawn_thread(_RenderLaunch, "VU view", B_NORMAL_PRIORITY, this); 79 fThreadId = spawn_thread(_RenderLaunch, "VU view", B_NORMAL_PRIORITY, 80 this); 80 81 if (fThreadId < 0) 81 82 return; 82 83 resume_thread(fThreadId); … … 138 139 } else { 139 140 SHIFT_UNTIL(levels[i][channel].red, 7, back_color.red); 140 141 SHIFT_UNTIL(levels[i][channel].blue, 7, back_color.blue); 141 SHIFT_UNTIL(levels[i][channel].green, 14, back_color.green); 142 SHIFT_UNTIL(levels[i][channel].green, 14, 143 back_color.green); 142 144 } 143 145 } 144 146 } … … 173 175 174 176 template<typename T> 175 177 T 176 VUView::_ComputeNextLevel(void *data, size_t size, uint32 format, int32 channel) 178 VUView::_ComputeNextLevel(void *data, size_t size, uint32 format, 179 int32 channel) 177 180 { 178 181 T* samp = (T*)data; 179 182 -
src/apps/soundrecorder/Jamfile
20 20 UpDownButton.cpp 21 21 VUView.cpp 22 22 VolumeSlider.cpp 23 : be media tracker $(TARGET_LIBSTDC++)23 : be locale media tracker $(TARGET_LIBSTDC++) 24 24 : SoundRecorder.rdef 25 25 ; 26 26 27 DoCatalogs SoundRecorder : 28 x-vnd.Haiku-SoundRecorder 29 : 30 RecorderWindow.cpp 31 SoundListView.cpp 32 ; 33 34 -
src/apps/soundrecorder/TransportButton.cpp
2 2 * Copyright 2005, Jérôme Duval. All rights reserved. 3 3 * Distributed under the terms of the MIT License. 4 4 * 5 * Inspired by SoundCapture from Be newsletter (Media Kit Basics: Consumers and Producers) 5 * Inspired by SoundCapture from Be newsletter (Media Kit Basics: Consumers 6 * and Producers) 6 7 */ 7 8 8 9 #include <Bitmap.h> … … 56 57 BitmapStash::~BitmapStash() 57 58 { 58 59 // delete all the bitmaps 59 for (map<uint32, BBitmap *>::iterator i = stash.begin(); i != stash.end(); i++) 60 for (map<uint32, BBitmap *>::iterator i = stash.begin(); 61 i != stash.end(); i++) 60 62 delete (*i).second; 61 63 } 62 64 … … 100 102 PeriodicMessageSender::Launch(BMessenger target, const BMessage *message, 101 103 bigtime_t period) 102 104 { 103 PeriodicMessageSender *result = new PeriodicMessageSender(target, message, period); 105 PeriodicMessageSender *result = new PeriodicMessageSender(target, 106 message, period); 104 107 thread_id thread = spawn_thread(&PeriodicMessageSender::TrackBinder, 105 108 "ButtonRepeatingThread", B_NORMAL_PRIORITY, result); 106 109 … … 209 212 BMessage *invokeMessage, BMessage *startPressingMessage, 210 213 BMessage *pressingMessage, BMessage *donePressingMessage, bigtime_t period, 211 214 uint32 key, uint32 modifiers, uint32 resizeFlags) 212 : BControl(frame, name, "", invokeMessage, resizeFlags, B_WILL_DRAW | B_NAVIGABLE), 215 : BControl(frame, name, "", invokeMessage, resizeFlags, 216 B_WILL_DRAW | B_NAVIGABLE), 213 217 bitmaps(new BitmapStash(this)), 214 218 normalBits(normalBits), 215 219 pressedBits(pressedBits), … … 301 305 TransportButton::MakeBitmap(uint32 mask) 302 306 { 303 307 BBitmap *result = new BBitmap(Bounds(), B_CMAP8); 304 result->SetBits(BitsForMask(mask), (Bounds().Width() + 1) * (Bounds().Height() + 1),305 0, B_CMAP8);308 result->SetBits(BitsForMask(mask), (Bounds().Width() + 1) 309 * (Bounds().Height() + 1), 0, B_CMAP8); 306 310 307 311 ReplaceTransparentColor(result, Parent()->ViewColor()); 308 312 … … 493 497 PlayPauseButton::PlayPauseButton(BRect frame, const char *name, 494 498 BMessage *invokeMessage, BMessage *blinkMessage, 495 499 uint32 key, uint32 modifiers, uint32 resizeFlags) 496 : TransportButton(frame, name, kPlayButtonBitmapBits, kPressedPlayButtonBitmapBits, 500 : TransportButton(frame, name, kPlayButtonBitmapBits, 501 kPressedPlayButtonBitmapBits, 497 502 kDisabledPlayButtonBitmapBits, invokeMessage, NULL, 498 503 NULL, NULL, 0, key, modifiers, resizeFlags), 499 504 fState(PlayPauseButton::kStopped), … … 616 621 } else if (fState == kAboutToPlay) { 617 622 fState = kPlayingLedOn; 618 623 if (!fRunner && fBlinkMessage) 619 fRunner = new BMessageRunner(Messenger(), fBlinkMessage, kPlayingBlinkPeriod); 624 fRunner = new BMessageRunner(Messenger(), fBlinkMessage, 625 kPlayingBlinkPeriod); 620 626 } 621 627 622 628 _inherited::DonePressing(); … … 626 632 RecordButton::RecordButton(BRect frame, const char *name, 627 633 BMessage *invokeMessage, BMessage *blinkMessage, 628 634 uint32 key, uint32 modifiers, uint32 resizeFlags) 629 : TransportButton(frame, name, kRecordButtonBitmapBits, kPressedRecordButtonBitmapBits, 635 : TransportButton(frame, name, kRecordButtonBitmapBits, 636 kPressedRecordButtonBitmapBits, 630 637 kDisabledRecordButtonBitmapBits, invokeMessage, NULL, NULL, 631 638 NULL, 0, key, modifiers, resizeFlags), 632 639 fState(RecordButton::kStopped), … … 675 682 if (Value()) 676 683 result = kPressedMask; 677 684 678 if (fState == kAboutToStop || fState == kRecordingLedOn) 685 if (fState == kAboutToStop || fState == kRecordingLedOn) 679 686 result |= kRecordingMask; 680 687 681 688 return result; … … 729 736 } else if (fState == kAboutToRecord) { 730 737 fState = kRecordingLedOn; 731 738 if (!fRunner && fBlinkMessage) 732 fRunner = new BMessageRunner(Messenger(), fBlinkMessage, kRecordingBlinkPeriod); 739 fRunner = new BMessageRunner(Messenger(), fBlinkMessage, 740 kRecordingBlinkPeriod); 733 741 } 734 742 735 743 _inherited::DonePressing(); -
src/apps/soundrecorder/RecorderWindow.cpp
56 56 #define CONNECT FPRINTF 57 57 #define WINDOW FPRINTF 58 58 59 #undef B_TRANSLATE_CONTEXT 60 #define B_TRANSLATE_CONTEXT "RecorderWindow" 61 62 59 63 // default window positioning 60 64 static const float MIN_WIDTH = 400.0f; 61 65 static const float MIN_HEIGHT = 336.0f; … … 108 112 fPlayFrames(0), 109 113 fLooping(false), 110 114 fSavePanel(NULL), 111 fInitCheck(B_OK) 115 fInitCheck(B_OK), 116 fAppCatalog(NULL) 112 117 { 113 118 fRoster = NULL; 114 119 fRecordButton = NULL; … … 124 129 125 130 CalcSizes(MIN_WIDTH, MIN_HEIGHT); 126 131 132 be_locale->GetAppCatalog(&fAppCatalog); 133 134 SetTitle(B_TRANSLATE("SoundRecorder")); 135 127 136 fInitCheck = InitWindow(); 128 137 if (fInitCheck != B_OK) { 129 138 if (fInitCheck == B_NAME_NOT_FOUND) 130 ErrorAlert("find default audio hardware", fInitCheck); 139 ErrorAlert(B_TRANSLATE("Cannot find default audio hardware"), 140 fInitCheck); 131 141 else 132 ErrorAlert("connect to media server", fInitCheck); 142 ErrorAlert(B_TRANSLATE("Cannot connect to media server"), 143 fInitCheck); 133 144 PostMessage(B_QUIT_REQUESTED); 134 145 } else 135 146 Show(); … … 277 288 // Button for rewinding 278 289 buttonRect = BRect(BPoint(0,0), kSkipButtonSize); 279 290 buttonRect.OffsetTo(background->Bounds().LeftBottom() - BPoint(-7, 25)); 280 fRewindButton = new TransportButton(buttonRect, "Rewind",291 fRewindButton = new TransportButton(buttonRect, B_TRANSLATE("Rewind"), 281 292 kSkipBackBitmapBits, kPressedSkipBackBitmapBits, 282 293 kDisabledSkipBackBitmapBits, new BMessage(REWIND)); 283 294 background->AddChild(fRewindButton); … … 285 296 // Button for stopping recording or playback 286 297 buttonRect = BRect(BPoint(0,0), kStopButtonSize); 287 298 buttonRect.OffsetTo(background->Bounds().LeftBottom() - BPoint(-48, 25)); 288 fStopButton = new TransportButton(buttonRect, "Stop",299 fStopButton = new TransportButton(buttonRect, B_TRANSLATE("Stop"), 289 300 kStopButtonBitmapBits, kPressedStopButtonBitmapBits, 290 301 kDisabledStopButtonBitmapBits, new BMessage(STOP)); 291 302 background->AddChild(fStopButton); … … 293 304 // Button for starting playback of selected sound 294 305 BRect playRect(BPoint(0,0), kPlayButtonSize); 295 306 playRect.OffsetTo(background->Bounds().LeftBottom() - BPoint(-82, 25)); 296 fPlayButton = new PlayPauseButton(playRect, "Play",307 fPlayButton = new PlayPauseButton(playRect, B_TRANSLATE("Play"), 297 308 new BMessage(PLAY), new BMessage(PLAY_PERIOD), ' ', 0); 298 309 background->AddChild(fPlayButton); 299 310 300 311 // Button for forwarding 301 312 buttonRect = BRect(BPoint(0,0), kSkipButtonSize); 302 313 buttonRect.OffsetTo(background->Bounds().LeftBottom() - BPoint(-133, 25)); 303 fForwardButton = new TransportButton(buttonRect, "Forward",314 fForwardButton = new TransportButton(buttonRect, B_TRANSLATE("Forward"), 304 315 kSkipForwardBitmapBits, kPressedSkipForwardBitmapBits, 305 316 kDisabledSkipForwardBitmapBits, new BMessage(FORWARD)); 306 317 background->AddChild(fForwardButton); … … 308 319 // Button to start recording (or waiting for sound) 309 320 buttonRect = BRect(BPoint(0,0), kRecordButtonSize); 310 321 buttonRect.OffsetTo(background->Bounds().LeftBottom() - BPoint(-174, 25)); 311 fRecordButton = new RecordButton(buttonRect, "Record",322 fRecordButton = new RecordButton(buttonRect, B_TRANSLATE("Record"), 312 323 new BMessage(RECORD), new BMessage(RECORD_PERIOD)); 313 324 background->AddChild(fRecordButton); 314 325 315 326 // Button for saving selected sound 316 327 buttonRect = BRect(BPoint(0,0), kDiskButtonSize); 317 328 buttonRect.OffsetTo(background->Bounds().LeftBottom() - BPoint(-250, 21)); 318 fSaveButton = new TransportButton(buttonRect, "Save",329 fSaveButton = new TransportButton(buttonRect, B_TRANSLATE("Save"), 319 330 kDiskButtonBitmapsBits, kPressedDiskButtonBitmapsBits, 320 331 kDisabledDiskButtonBitmapsBits, new BMessage(SAVE)); 321 332 fSaveButton->SetResizingMode(B_FOLLOW_RIGHT | B_FOLLOW_TOP); … … 324 335 // Button Loop 325 336 buttonRect = BRect(BPoint(0,0), kArrowSize); 326 337 buttonRect.OffsetTo(background->Bounds().RightBottom() - BPoint(23, 48)); 327 fLoopButton = new DrawButton(buttonRect, "Loop",338 fLoopButton = new DrawButton(buttonRect, B_TRANSLATE("Loop"), 328 339 kLoopArrowBits, kArrowBits, new BMessage(LOOP)); 329 340 fLoopButton->SetResizingMode(B_FOLLOW_RIGHT | B_FOLLOW_TOP); 330 341 fLoopButton->SetTarget(this); … … 366 377 r.top += 4; 367 378 r.right -= B_V_SCROLL_BAR_WIDTH; 368 379 r.bottom -= 25; 369 fSoundList = new SoundListView(r, "Sound List", B_FOLLOW_ALL); 380 fSoundList = new SoundListView(r, B_TRANSLATE("Sound List"), 381 B_FOLLOW_ALL); 370 382 fSoundList->SetSelectionMessage(new BMessage(SOUND_SELECTED)); 371 383 fSoundList->SetViewColor(216, 216, 216); 372 384 BScrollView *scroller = new BScrollView("scroller", fSoundList, … … 379 391 r.InsetBy(10, 8); 380 392 r.top -= 1; 381 393 fFileInfoBox = new BBox(r, "fileinfo", B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); 382 fFileInfoBox->SetLabel( "File info");394 fFileInfoBox->SetLabel(B_TRANSLATE("File info")); 383 395 384 396 r = fFileInfoBox->Bounds(); 385 397 r.left = 8; 386 398 r.top = 13; 387 399 r.bottom = r.top + 15; 388 400 r.right -= 10; 389 fFilename = new BStringView(r, "filename", "File name:");401 fFilename = new BStringView(r, "filename", B_TRANSLATE("File name:")); 390 402 fFileInfoBox->AddChild(fFilename); 391 403 r.top += 13; 392 404 r.bottom = r.top + 15; 393 fFormat = new BStringView(r, "format", "Format:");405 fFormat = new BStringView(r, "format", B_TRANSLATE("Format:")); 394 406 fFileInfoBox->AddChild(fFormat); 395 407 r.top += 13; 396 408 r.bottom = r.top + 15; 397 fCompression = new BStringView(r, "compression", "Compression:"); 409 fCompression = new BStringView(r, "compression", 410 B_TRANSLATE("Compression:")); 398 411 fFileInfoBox->AddChild(fCompression); 399 412 r.top += 13; 400 413 r.bottom = r.top + 15; 401 fChannels = new BStringView(r, "channels", "Channels:");414 fChannels = new BStringView(r, "channels", B_TRANSLATE("Channels:")); 402 415 fFileInfoBox->AddChild(fChannels); 403 416 r.top += 13; 404 417 r.bottom = r.top + 15; 405 fSampleSize = new BStringView(r, "samplesize", "Sample size:"); 418 fSampleSize = new BStringView(r, "samplesize", 419 B_TRANSLATE("Sample size:")); 406 420 fFileInfoBox->AddChild(fSampleSize); 407 421 r.top += 13; 408 422 r.bottom = r.top + 15; 409 fSampleRate = new BStringView(r, "samplerate", "Sample rate:"); 423 fSampleRate = new BStringView(r, "samplerate", 424 B_TRANSLATE("Sample rate:")); 410 425 fFileInfoBox->AddChild(fSampleRate); 411 426 r.top += 13; 412 427 r.bottom = r.top + 15; 413 fDuration = new BStringView(r, "duration", "Duration:");428 fDuration = new BStringView(r, "duration", B_TRANSLATE("Duration:")); 414 429 fFileInfoBox->AddChild(fDuration); 415 430 416 431 // Input selection lists all available physical inputs that produce 417 432 // buffers with B_MEDIA_RAW_AUDIO format data. 418 popup = new BPopUpMenu( "Input");433 popup = new BPopUpMenu(B_TRANSLATE("Input")); 419 434 const int maxInputCount = 64; 420 435 dormant_node_info dni[maxInputCount]; 421 436 … … 456 471 r.right = (r.left + r.right) / 2; 457 472 r.InsetBy(10,10); 458 473 r.top = r.bottom - 18; 459 fInputField = new BMenuField(r, "Input", "Input:", popup);460 fInputField->SetDivider(fInputField->StringWidth( "Input:") + 4.0f);474 fInputField = new BMenuField(r, "Input", B_TRANSLATE("Input:"), popup); 475 fInputField->SetDivider(fInputField->StringWidth(B_TRANSLATE("Input:")) + 4.0f); 461 476 fBottomBox->AddChild(fInputField); 462 477 463 478 fBottomBox->AddChild(fFileInfoBox); … … 624 639 // Create a file with a temporary name 625 640 status_t err = NewTempName(name); 626 641 if (err < B_OK) { 627 ErrorAlert("find an unused name to use for the new recording", err); 642 ErrorAlert(B_TRANSLATE("Cannot find an unused name to use for the " 643 "new recording"), err); 628 644 return; 629 645 } 630 646 // Find the file so we can refer to it later 631 647 err = fTempDir.FindEntry(name, &fRecEntry); 632 648 if (err < B_OK) { 633 ErrorAlert("find the temporary file created to hold the new recording", err); 649 ErrorAlert(B_TRANSLATE("Cannot find the temporary file created to " 650 "hold the new recording"), err); 634 651 return; 635 652 } 636 653 err = fRecFile.SetTo(&fTempDir, name, O_RDWR); 637 654 if (err < B_OK) { 638 ErrorAlert("open the temporary file created to hold the new recording", err); 655 ErrorAlert(B_TRANSLATE("Cannot open the temporary file created to " 656 "hold the new recording"), err); 639 657 fRecEntry.Unset(); 640 658 return; 641 659 } 642 660 // Reserve space on disk (creates fewer fragments) 643 661 err = fRecFile.SetSize(4 * fRecordFormat.u.raw_audio.channel_count 644 * fRecordFormat.u.raw_audio.frame_rate * (fRecordFormat.u.raw_audio.format 645 & media_raw_audio_format::B_AUDIO_SIZE_MASK)); 662 * fRecordFormat.u.raw_audio.frame_rate 663 * (fRecordFormat.u.raw_audio.format 664 & media_raw_audio_format::B_AUDIO_SIZE_MASK)); 646 665 if (err < B_OK) { 647 ErrorAlert( "record a sound that long", err);666 ErrorAlert(B_TRANSLATE("Cannot record a sound that long"), err); 648 667 fRecEntry.Remove(); 649 668 fRecEntry.Unset(); 650 669 return; … … 656 675 // Hook up input 657 676 err = MakeRecordConnection(fAudioInputNode); 658 677 if (err < B_OK) { 659 ErrorAlert("connect to the selected sound input", err); 678 ErrorAlert(B_TRANSLATE("Cannot connect to the selected sound input"), 679 err); 660 680 fRecEntry.Remove(); 661 681 fRecEntry.Unset(); 662 682 return; … … 692 712 fPlayButton->SetPlaying(); 693 713 694 714 if (!fPlayTrack) { 695 ErrorAlert( "get the file to play", B_ERROR);715 ErrorAlert(B_TRANSLATE("Cannot get the file to play"), B_ERROR); 696 716 return; 697 717 } 698 718 … … 702 722 fPlayFrame = fPlayTrack->CurrentFrame(); 703 723 704 724 // Create our internal Node which plays sound, and register it. 705 fPlayer = new BSoundPlayer(fAudioMixerNode, &fPlayFormat.u.raw_audio, "Sound Player"); 725 fPlayer = new BSoundPlayer(fAudioMixerNode, &fPlayFormat.u.raw_audio, 726 "Sound Player"); 706 727 status_t err = fPlayer->InitCheck(); 707 728 if (err < B_OK) { 708 729 return; … … 830 851 return; 831 852 status_t err = UpdatePlayFile(pItem, true); 832 853 if (err != B_OK) { 833 ErrorAlert( "recognize this file as a media file",854 ErrorAlert(B_TRANSLATE("Cannot recognize this file as a media file"), 834 855 err == B_MEDIA_NO_HANDLER ? B_OK : err); 835 856 RemoveCurrentSoundItem(); 836 857 } … … 913 934 return err; 914 935 } 915 936 916 // Using the same structs for input and output is OK in BMediaRoster::Connect(). 917 err = fRoster->Connect(fAudioOutput.source, fRecInput.destination, &fRecordFormat, &fAudioOutput, &fRecInput); 937 // Using the same structs for input and output is OK in 938 // BMediaRoster::Connect(). 939 err = fRoster->Connect(fAudioOutput.source, fRecInput.destination, 940 &fRecordFormat, &fAudioOutput, &fRecInput); 918 941 if (err < B_OK) { 919 942 CONNECT((stderr, "RecorderWindow::MakeRecordConnection():" 920 943 " failed to connect sound recorder to audio input node.\n")); … … 978 1001 fRecFile.Seek(0, SEEK_SET); 979 1002 fRecFile.Write(&header, sizeof(header)); 980 1003 981 fRecFile.SetSize(fRecSize + sizeof(header)); // We reserve space; make sure we cut off any excess at the end. 1004 fRecFile.SetSize(fRecSize + sizeof(header)); 1005 // We reserve space; make sure we cut off any excess at the end. 982 1006 AddSoundItem(fRecEntry, true); 983 1007 } 984 1008 else { … … 1037 1061 } 1038 1062 1039 1063 #ifndef __HAIKU__ 1040 extern "C" status_t DecodedFormat__11BMediaTrackP12media_format(BMediaTrack *self, media_format *inout_format); 1064 extern "C" status_t DecodedFormat__11BMediaTrackP12media_format( 1065 BMediaTrack *self, media_format *inout_format); 1041 1066 #endif 1042 1067 1043 1068 … … 1093 1118 if (!updateDisplay) 1094 1119 return B_OK; 1095 1120 1096 BString filename = "File name: ";1121 BString filename = B_TRANSLATE("File name: "); 1097 1122 filename << ref.name; 1098 1123 fFilename->SetText(filename.String()); 1099 1124 1100 BString format = "Format: ";1125 BString format = B_TRANSLATE("Format: "); 1101 1126 media_file_format file_format; 1102 1127 if (fPlayFile->GetFileFormatInfo(&file_format) == B_OK) 1103 1128 format << file_format.short_name; 1104 BString compression = "Compression: ";1129 BString compression = B_TRANSLATE("Compression: "); 1105 1130 media_codec_info codec_info; 1106 1131 if (fPlayTrack->GetCodecInfo(&codec_info) == B_OK) { 1107 1132 if (strcmp(codec_info.short_name, "raw")==0) 1108 compression << "None";1133 compression << B_TRANSLATE("None"); 1109 1134 else 1110 1135 compression << codec_info.short_name; 1111 1136 } 1112 BString channels = "Channels: ";1137 BString channels = B_TRANSLATE("Channels: "); 1113 1138 channels << fPlayFormat.u.raw_audio.channel_count; 1114 BString samplesize = "Sample size: "; 1115 samplesize << 8 * (fPlayFormat.u.raw_audio.format & 0xf) << " bits"; 1116 BString samplerate = "Sample rate: "; 1139 BString samplesize = B_TRANSLATE("Sample size: "); 1140 samplesize << 8 * (fPlayFormat.u.raw_audio.format & 0xf) 1141 << B_TRANSLATE(" bits"); 1142 BString samplerate = B_TRANSLATE("Sample rate: "); 1117 1143 samplerate << (int)fPlayFormat.u.raw_audio.frame_rate; 1118 BString durationString = "Duration: ";1144 BString durationString = B_TRANSLATE("Duration: "); 1119 1145 bigtime_t duration = fPlayTrack->Duration(); 1120 durationString << (float)(duration / 1000000.0) << " seconds";1146 durationString << (float)(duration / 1000000.0) << B_TRANSLATE(" seconds"); 1121 1147 1122 1148 fFormat->SetText(format.String()); 1123 1149 fCompression->SetText(compression.String()); … … 1140 1166 { 1141 1167 char msg[300]; 1142 1168 if (err != B_OK) 1143 sprintf(msg, " Cannot%s: %s. [%lx]", action, strerror(err), (int32) err);1169 sprintf(msg, "%s: %s. [%lx]", action, strerror(err), (int32) err); 1144 1170 else 1145 sprintf(msg, " Cannot%s.", action);1146 (new BAlert("", msg, "Stop"))->Go();1171 sprintf(msg, "%s.", action); 1172 (new BAlert("", msg, B_TRANSLATE("Stop")))->Go(); 1147 1173 } 1148 1174 1149 1175 … … 1302 1328 } 1303 1329 1304 1330 if (countBad > 0 && countGood == 0) 1305 (new BAlert("Nothing to play", "None of the files appear to be " 1306 "audio files", "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go(); 1331 (new BAlert(B_TRANSLATE("Nothing to play"), B_TRANSLATE("None of the " 1332 "files appear to be audio files"), B_TRANSLATE("OK"), NULL, NULL, 1333 B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go(); 1307 1334 else if (countGood > 0) { 1308 1335 if (countBad > 0) 1309 (new BAlert("Invalid audio files", "Some of the files " 1310 "don't appear to be audio files", "OK", NULL, NULL, 1311 B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go(); 1336 (new BAlert(B_TRANSLATE("Invalid audio files"), B_TRANSLATE("Some " 1337 "of the files don't appear to be audio files"), 1338 B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, 1339 B_WARNING_ALERT))->Go(); 1312 1340 fSoundList->Select(fSoundList->CountItems() - 1); 1313 1341 } 1314 1342 } … … 1332 1360 bigtime_t start = fTrackSlider->LeftTime(); 1333 1361 1334 1362 // write data 1335 bigtime_t diffTime = fTrackSlider->RightTime() - fTrackSlider->LeftTime(); 1363 bigtime_t diffTime = fTrackSlider->RightTime() 1364 - fTrackSlider->LeftTime(); 1336 1365 int64 framesToWrite = (int64) (diffTime 1337 1366 * fPlayFormat.u.raw_audio.frame_rate / 1000000LL); 1338 1367 int32 frameSize = (fPlayFormat.u.raw_audio.format & 0xf) … … 1340 1369 1341 1370 wave_struct header; 1342 1371 header.riff.riff_id = FOURCC('R','I','F','F'); 1343 header.riff.len = (frameSize * framesToWrite) + sizeof(header) - 8; 1372 header.riff.len 1373 = (frameSize * framesToWrite) + sizeof(header) - 8; 1344 1374 header.riff.wave_id = FOURCC('W','A','V','E'); 1345 1375 header.format_chunk.fourcc = FOURCC('f','m','t',' '); 1346 1376 header.format_chunk.len = sizeof(header.format); 1347 1377 header.format.format_tag = 1; 1348 1378 header.format.channels = fPlayFormat.u.raw_audio.channel_count; 1349 header.format.samples_per_sec = (uint32)fPlayFormat.u.raw_audio.frame_rate; 1350 header.format.avg_bytes_per_sec = (uint32)(fPlayFormat.u.raw_audio.frame_rate 1379 header.format.samples_per_sec 1380 = (uint32)fPlayFormat.u.raw_audio.frame_rate; 1381 header.format.avg_bytes_per_sec 1382 = (uint32)(fPlayFormat.u.raw_audio.frame_rate 1351 1383 * fPlayFormat.u.raw_audio.channel_count 1352 1384 * (fPlayFormat.u.raw_audio.format & 0xf)); 1353 header.format.bits_per_sample = (fPlayFormat.u.raw_audio.format & 0xf) * 8; 1385 header.format.bits_per_sample 1386 = (fPlayFormat.u.raw_audio.format & 0xf) * 8; 1354 1387 header.format.block_align = frameSize; 1355 1388 header.data_chunk.fourcc = FOURCC('d','a','t','a'); 1356 1389 header.data_chunk.len = frameSize * framesToWrite; -
src/apps/soundrecorder/UpDownButton.cpp
2 2 * Copyright 2005, Jérôme Duval. All rights reserved. 3 3 * Distributed under the terms of the MIT License. 4 4 * 5 * Inspired by SoundCapture from Be newsletter (Media Kit Basics: Consumers and Producers) 5 * Inspired by SoundCapture from Be newsletter (Media Kit Basics: Consumers 6 * and Producers) 6 7 */ 7 8 #include "UpDownButton.h" 8 9 #include "icon_button.h" … … 13 14 { 14 15 BRect rect = BRect(0, 0, kUpDownButtonWidth - 1, kUpDownButtonHeight - 1); 15 16 fBitmapUp = new BBitmap(rect, B_CMAP8); 16 fBitmapUp->SetBits(kButtonUpBits, kUpDownButtonWidth * kUpDownButtonHeight, 0, B_CMAP8); 17 fBitmapUp->SetBits(kButtonUpBits, kUpDownButtonWidth * kUpDownButtonHeight, 18 0, B_CMAP8); 17 19 fBitmapDown = new BBitmap(rect, B_CMAP8); 18 fBitmapDown->SetBits(kButtonDownBits, kUpDownButtonWidth * kUpDownButtonHeight, 0, B_CMAP8); 20 fBitmapDown->SetBits(kButtonDownBits, kUpDownButtonWidth 21 * kUpDownButtonHeight, 0, B_CMAP8); 19 22 fBitmapMiddle = new BBitmap(rect, B_CMAP8); 20 fBitmapMiddle->SetBits(kButtonMiddleBits, kUpDownButtonWidth * kUpDownButtonHeight, 0, B_CMAP8); 23 fBitmapMiddle->SetBits(kButtonMiddleBits, kUpDownButtonWidth 24 * kUpDownButtonHeight, 0, B_CMAP8); 21 25 } 22 26 23 27 -
src/apps/soundrecorder/DrawButton.cpp
8 8 #include "DrawButton.h" 9 9 #include "DrawingTidbits.h" 10 10 11 DrawButton::DrawButton(BRect frame, const char *name, const unsigned char *on, const unsigned char *off,12 11 DrawButton::DrawButton(BRect frame, const char *name, const unsigned char *on, 12 const unsigned char *off, BMessage *msg, int32 resize, int32 flags) 13 13 : BControl(frame, name, "", msg, resize, flags | B_WILL_DRAW), 14 14 fOn(frame, B_CMAP8), 15 15 fOff(frame, B_CMAP8),