Ticket #6107: soundrecoderLocalization.patch

File soundrecoderLocalization.patch, 53.3 KB (added by Karvjorm, 14 years ago)

A localization patch for SoundRecoder

  • src/apps/soundrecorder/FileUtils.cpp

     
    1 /*******************************************************************************
     1/******************************************************************************
    22/
    33/   File:           FileUtils.cpp
    44/
     
    66/
    77/   Copyright 1998-1999, Be Incorporated, All Rights Reserved
    88/
    9 *******************************************************************************/
     9******************************************************************************/
    1010#include "FileUtils.h"
    1111
    1212#include <new>
     
    102102        }
    103103        // NOTE: Attributes of size 0 are perfectly valid!
    104104        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);
    107107            if (written != read) {
    108108                fprintf(stderr, "Error writing attribute '%s'\n", attrName);
    109109                if (written < 0)
  • src/apps/soundrecorder/RecorderWindow.h

     
    88#ifndef RECORDERWINDOW_H
    99#define RECORDERWINDOW_H
    1010
     11#include <Catalog.h>
    1112#include <Directory.h>
    1213#include <Entry.h>
    1314#include <File.h>
    1415#include <FilePanel.h>
     16#include <Locale.h>
    1517#include <MediaFile.h>
    1618#include <MediaNode.h>
    1719#include <MediaTrack.h>
     
    167169               
    168170        void RefsReceived(BMessage *msg);
    169171        void CopyTarget(BMessage *msg);
     172        BCatalog fAppCatalog;
    170173};
    171174
    172175#endif  /*  RECORDERWINDOW_H */
  • src/apps/soundrecorder/ScopeView.cpp

     
    121121    int64 framesCount = fMediaTrack->CountFrames() / SAMPLES_COUNT;
    122122    if (framesCount <= 0)
    123123        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
    125126        & media_raw_audio_format::B_AUDIO_SIZE_MASK)];
    126127    int64 frames = 0;
    127128    U sum = 0;
     
    149150                break;
    150151           
    151152            if (sumCount >= framesCount) {
    152                 //TRACE("computing block %ld, sumCount %ld\n", previewIndex, sumCount);
     153                // TRACE("computing block %ld, sumCount %ld\n", previewIndex,
     154                // sumCount);
    153155                fPreview[previewIndex] = (int32)(sum
    154156                    / fPlayFormat.u.raw_audio.channel_count / framesCount);
    155157                if (previewMax < fPreview[previewIndex])
     
    164166    if (previewMax <= 0)
    165167        return;
    166168    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);
    168171}
    169172
    170173
  • src/apps/soundrecorder/SoundConsumer.cpp

     
    1 /*******************************************************************************
     1/******************************************************************************
    22/
    33/   File:           SoundConsumer.cpp
    44/
     
    66/
    77/   Copyright 1998-1999, Be Incorporated, All Rights Reserved
    88/
    9 *******************************************************************************/
     9******************************************************************************/
    1010#include "SoundConsumer.h"
    1111
    1212#include <new>
  • src/apps/soundrecorder/TrackSlider.cpp

     
    22 * Copyright 2005, Jérôme Duval. All rights reserved.
    33 * Distributed under the terms of the MIT License.
    44 *
    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)
    67 */
    78 
    89#include <stdio.h>
     
    1213#include "TrackSlider.h"
    1314#include "icon_button.h"
    1415
    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)
     16TrackSlider::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)
    2030{
    2131    fFont.SetSize(8.0);
    2232    fFont.SetFlags(B_DISABLE_ANTIALIASING);
     
    7484        fBitmapView->fRightX = fBitmapView->fRight;
    7585        fBitmapView->fPositionX = 15;
    7686    } 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);
    8093    }
    8194}
    8295
     
    132145   
    133146    BeginLineArray(4);
    134147    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);
    139156        SetHighColor(216,216,216);
    140157    } 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);
    145166        SetHighColor(48,48,241);
    146167    }
    147168    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));
    149171
    150172#ifdef __HAIKU__
    151173    SetDrawingMode(B_OP_OVER);
     
    174196    rgb_color white = {255,255,255};
    175197       
    176198    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);
    182209   
    183210   
    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);
    186215   
    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);
    190222   
    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);
    192225   
    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);
    199238   
    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);
    201241   
    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);
    205248   
    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);
    207251   
    208252    EndLineArray();
    209253}
     
    237281
    238282    _UpdatePosition(point);
    239283    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);
    241286}
    242287
    243288
     
    262307void
    263308TrackSlider::_UpdatePosition(BPoint point)
    264309{
    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);
    267314   
    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)))) {
    269317        if (!IsTracking())
    270318            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);
    273323        fLeftTracking = true;
    274324       
    275325        BMessage msg = *Message();
     
    290340        _RenderBitmap();
    291341       
    292342        //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)))) {
    294346        if (!IsTracking())
    295347            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);
    298352        fRightTracking = true;
    299353       
    300354        BMessage msg = *Message();
     
    317371        //printf("fRightPos : %Ld\n", fRightTime);
    318372    } else {
    319373        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);
    321376        fMainTracking = true;
    322377       
    323378        BMessage msg = *Message();
     
    353408    uint32 seconds = timestamp / 1000000LL;
    354409    timestamp -= seconds * 1000000LL;
    355410    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);
    358413}
    359414
    360415
     
    362417TrackSlider::SetMainTime(bigtime_t timestamp, bool reset)
    363418{
    364419    fMainTime = timestamp;
    365     fBitmapView->fPositionX = 15 + (fBitmapView->fRight - 14) * ((double)fMainTime / fTotalTime);
     420    fBitmapView->fPositionX = 15 + (fBitmapView->fRight - 14)
     421        * ((double)fMainTime / fTotalTime);
    366422    if (reset) {
    367423        fRightTime = fTotalTime;
    368424        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);
    371429        _RenderBitmap();
    372430    }
    373431    Invalidate();
     
    382440        fRightTime = fTotalTime;
    383441        fLeftTime = 0;
    384442    }
    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);
    388449    _RenderBitmap();
    389450    Invalidate();
    390451}
     
    394455TrackSlider::ResetMainTime()
    395456{
    396457    fMainTime = fLeftTime;
    397     fBitmapView->fPositionX = 15 + (fBitmapView->fRight - 14) * ((double)fMainTime / fTotalTime);
     458    fBitmapView->fPositionX = 15 + (fBitmapView->fRight - 14)
     459        * ((double)fMainTime / fTotalTime);
    398460    Invalidate();
    399461}
    400462
     
    403465TrackSlider::FrameResized(float width, float height)
    404466{
    405467    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);
    407470    _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);
    410475    _RenderBitmap();
    411476    Invalidate();
    412477}
     
    416481    : BView(frame, name, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW),
    417482    leftBitmap(BRect(BPoint(0,0), kLeftRightTrackSliderSize), B_CMAP8),
    418483    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)
    421488{
    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);
    426497}
    427498
    428499
     
    451522    SetLowColor(HighColor());
    452523
    453524    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)),
    455527        BRect(leftPoint, leftPoint + kLeftRightTrackSliderSize - BPoint(5, 0)));
    456528    BPoint rightPoint(fRight + 1, SLIDER_BASE + 1);
    457529    DrawBitmapAsync(&rightBitmap, BRect(BPoint(5, 0), kLeftRightTrackSliderSize),
     
    461533    FillRect(BRect(11, SLIDER_BASE + 3, fLeftX - 9, SLIDER_BASE + 16));
    462534    FillRect(BRect(fRightX + 9, SLIDER_BASE + 3, fRight, SLIDER_BASE + 16));
    463535    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));
    470548    }
    471549    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));
    478562    }
    479563    SetHighColor(144, 186, 136);
    480564    FillRect(BRect(fLeftX + 1, SLIDER_BASE + 3, fRightX, SLIDER_BASE + 4));
     
    524608    SetLowColor(HighColor());
    525609   
    526610    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)));
    529615   
    530616    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)));
    533621   
    534622    Sync();
    535623}
  • src/apps/soundrecorder/SoundUtils.cpp

     
    1 /*******************************************************************************
     1/******************************************************************************
    22/
    33/   File:           SoundUtils.cpp
    44/
     
    66/
    77/   Copyright 1998-1999, Be Incorporated, All Rights Reserved
    88/
    9 *******************************************************************************/
     9******************************************************************************/
    1010
    1111#include <math.h>
    1212#include "SoundUtils.h"
     
    5858    //  Figuring out duration is easy. We take extra precaution to
    5959    //  not divide by zero or return irrelevant results.
    6060    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) {
    6263        //  In these kinds of calculations, it's always useful to double-check
    6364        //  the unit conversions. (Anyone remember high school physics?)
    6465        //  bytes/(bytes/frame) / frames/sec
    6566        //  = frames * sec/frames
    6667        //  = 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);
    6870    }
    6971    return duration;
    7072}
     
    8789    const media_raw_audio_format & format, bigtime_t duration)
    8890{
    8991    // 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
    9194    int buffers = 0;
    9295    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)));
    9498    }
    9599    return buffers;
    96100}
  • src/apps/soundrecorder/VolumeSlider.cpp

     
    22 * Copyright 2005, Jérôme Duval. All rights reserved.
    33 * Distributed under the terms of the MIT License.
    44 *
    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)
    67 */
    78 
    89#include <stdio.h>
     
    1415#define RATIO 2.0f
    1516
    1617VolumeSlider::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),
    2024    fButtonBitmap(BRect(0, 0, kThumbWidth - 1, kThumbHeight - 1), B_CMAP8),
    2125    fSoundPlayer(NULL)
    2226{
    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);
    2531    fButtonBitmap.SetBits(kThumbBits, kThumbWidth * kThumbHeight, 0, B_CMAP8);
    2632
    2733    fRight = Bounds().right - 15;   
     
    5359    DrawBitmapAsync(&fLeftBitmap, BPoint(5,1));
    5460    DrawBitmapAsync(&fRightBitmap, BPoint(fRight + 1,1));
    5561
    56     float position = 11 + (fRight - 11) * (fSoundPlayer ? fSoundPlayer->Volume() / RATIO : 0);
     62    float position = 11 + (fRight - 11) * (fSoundPlayer
     63        ? fSoundPlayer->Volume() / RATIO : 0);
    5764    SetHighColor(102,152,102);
    5865    FillRect(BRect(11,3,position,4));
    5966    SetHighColor(152,203,152);
     
    153160
    154161SpeakerView::SpeakerView(BRect rect, uint32 resizeFlags)
    155162    : 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)
    157165{
    158     fSpeakerBitmap.SetBits(kSpeakerIconBits, kSpeakerIconBitmapWidth * kSpeakerIconBitmapHeight, 0, B_CMAP8);
     166    fSpeakerBitmap.SetBits(kSpeakerIconBits, kSpeakerIconBitmapWidth
     167        * kSpeakerIconBitmapHeight, 0, B_CMAP8);
    159168}
    160169
    161170
  • src/apps/soundrecorder/DrawingTidbits.cpp

     
    22 * Copyright 2005, Jérôme Duval. All rights reserved.
    33 * Distributed under the terms of the MIT License.
    44 *
    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)
    67 */
    78
    89#include <Bitmap.h>
     
    4849void
    4950ReplaceColor(BBitmap *bitmap, rgb_color from, rgb_color to)
    5051{
    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
    5254   
    5355    BScreen screen(B_MAIN_SCREEN_ID);
    5456    uint32 fromIndex = screen.IndexForColor(from);
     
    6466void
    6567ReplaceTransparentColor(BBitmap *bitmap, rgb_color with)
    6668{
    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
    6871   
    6972    BScreen screen(B_MAIN_SCREEN_ID);
    7073    uint8 withIndex = screen.IndexForColor(with);
  • src/apps/soundrecorder/SoundListView.cpp

     
    22 * Copyright 2005, Jérôme Duval. All rights reserved.
    33 * Distributed under the terms of the MIT License.
    44 *
    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)
    67 */
     8#include <Catalog.h>
    79#include <Entry.h>
     10#include <Locale.h>
    811
    912#include "SoundListView.h"
    1013
    1114
     15#undef B_TRANSLATE_CONTEXT
     16#define B_TRANSLATE_CONTEXT "SoundListView"
     17
     18
    1219SoundListView::SoundListView(
    1320    const BRect & area,
    1421    const char * name,
     
    3643        SetFont(&font);
    3744        font_height height;
    3845        font.GetHeight(&height);
    39         float width = font.StringWidth("Drop files here");
     46        float width = font.StringWidth(B_TRANSLATE("Drop files here"));
    4047
    4148        BPoint pt;
    4249        pt.x = (Bounds().Width() - width) / 2;
    4350        pt.y = (Bounds().Height() + height.ascent + height.descent)/ 2;
    44         DrawString("Drop files here", pt);
     51        DrawString(B_TRANSLATE("Drop files here"), pt);
    4552    }
    4653    BListView::Draw(updateRect);
    4754}
  • src/apps/soundrecorder/VUView.cpp

     
    7676void
    7777VUView::_Run()
    7878{
    79     fThreadId = spawn_thread(_RenderLaunch, "VU view", B_NORMAL_PRIORITY, this);
     79    fThreadId = spawn_thread(_RenderLaunch, "VU view", B_NORMAL_PRIORITY,
     80        this);
    8081    if (fThreadId < 0)
    8182        return;
    8283    resume_thread(fThreadId);
     
    138139                } else {
    139140                    SHIFT_UNTIL(levels[i][channel].red, 7, back_color.red);
    140141                    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);
    142144                }
    143145            }
    144146        }
     
    173175
    174176template<typename T>
    175177T
    176 VUView::_ComputeNextLevel(void *data, size_t size, uint32 format, int32 channel)
     178VUView::_ComputeNextLevel(void *data, size_t size, uint32 format,
     179    int32 channel)
    177180{
    178181    T* samp = (T*)data;
    179182   
  • src/apps/soundrecorder/Jamfile

     
    2020    UpDownButton.cpp
    2121    VUView.cpp
    2222    VolumeSlider.cpp
    23     : be media tracker $(TARGET_LIBSTDC++)
     23    : be locale media tracker $(TARGET_LIBSTDC++)
    2424    : SoundRecorder.rdef
    2525;
    2626
     27DoCatalogs SoundRecorder :
     28    x-vnd.Haiku-SoundRecorder
     29    :
     30    RecorderWindow.cpp
     31    SoundListView.cpp
     32;
     33
     34
  • src/apps/soundrecorder/TransportButton.cpp

     
    22 * Copyright 2005, Jérôme Duval. All rights reserved.
    33 * Distributed under the terms of the MIT License.
    44 *
    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)
    67 */
    78
    89#include <Bitmap.h>
     
    5657BitmapStash::~BitmapStash()
    5758{
    5859    // 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++)
    6062        delete (*i).second;
    6163}
    6264
     
    100102PeriodicMessageSender::Launch(BMessenger target, const BMessage *message,
    101103    bigtime_t period)
    102104{
    103     PeriodicMessageSender *result = new PeriodicMessageSender(target, message, period);
     105    PeriodicMessageSender *result = new PeriodicMessageSender(target,
     106        message, period);
    104107    thread_id thread = spawn_thread(&PeriodicMessageSender::TrackBinder,
    105108        "ButtonRepeatingThread", B_NORMAL_PRIORITY, result);
    106109   
     
    209212    BMessage *invokeMessage, BMessage *startPressingMessage,
    210213    BMessage *pressingMessage, BMessage *donePressingMessage, bigtime_t period,
    211214    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),
    213217        bitmaps(new BitmapStash(this)),
    214218        normalBits(normalBits),
    215219        pressedBits(pressedBits),
     
    301305TransportButton::MakeBitmap(uint32 mask)
    302306{
    303307    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);
    306310
    307311    ReplaceTransparentColor(result, Parent()->ViewColor());
    308312   
     
    493497PlayPauseButton::PlayPauseButton(BRect frame, const char *name,
    494498    BMessage *invokeMessage, BMessage *blinkMessage,
    495499    uint32 key, uint32 modifiers, uint32 resizeFlags)
    496     :   TransportButton(frame, name, kPlayButtonBitmapBits, kPressedPlayButtonBitmapBits,
     500    :   TransportButton(frame, name, kPlayButtonBitmapBits,
     501            kPressedPlayButtonBitmapBits,
    497502            kDisabledPlayButtonBitmapBits, invokeMessage, NULL,
    498503            NULL, NULL, 0, key, modifiers, resizeFlags),
    499504        fState(PlayPauseButton::kStopped),
     
    616621    } else if (fState == kAboutToPlay) {
    617622        fState = kPlayingLedOn;
    618623        if (!fRunner && fBlinkMessage)
    619             fRunner = new BMessageRunner(Messenger(), fBlinkMessage, kPlayingBlinkPeriod);
     624            fRunner = new BMessageRunner(Messenger(), fBlinkMessage,
     625                kPlayingBlinkPeriod);
    620626    }
    621627   
    622628    _inherited::DonePressing();
     
    626632RecordButton::RecordButton(BRect frame, const char *name,
    627633    BMessage *invokeMessage, BMessage *blinkMessage,
    628634    uint32 key, uint32 modifiers, uint32 resizeFlags)
    629     :   TransportButton(frame, name, kRecordButtonBitmapBits, kPressedRecordButtonBitmapBits,
     635    :   TransportButton(frame, name, kRecordButtonBitmapBits,
     636            kPressedRecordButtonBitmapBits,
    630637            kDisabledRecordButtonBitmapBits, invokeMessage, NULL, NULL,
    631638            NULL, 0, key, modifiers, resizeFlags),
    632639        fState(RecordButton::kStopped),
     
    675682    if (Value())
    676683        result = kPressedMask;
    677684
    678     if (fState == kAboutToStop || fState == kRecordingLedOn)       
     685    if (fState == kAboutToStop || fState == kRecordingLedOn)
    679686        result |= kRecordingMask;
    680687   
    681688    return result;
     
    729736    } else if (fState == kAboutToRecord) {
    730737        fState = kRecordingLedOn;
    731738        if (!fRunner && fBlinkMessage)
    732             fRunner = new BMessageRunner(Messenger(), fBlinkMessage, kRecordingBlinkPeriod);
     739            fRunner = new BMessageRunner(Messenger(), fBlinkMessage,
     740                kRecordingBlinkPeriod);
    733741    }
    734742   
    735743    _inherited::DonePressing();
  • src/apps/soundrecorder/RecorderWindow.cpp

     
    5656#define CONNECT FPRINTF
    5757#define WINDOW FPRINTF
    5858
     59#undef B_TRANSLATE_CONTEXT
     60#define B_TRANSLATE_CONTEXT "RecorderWindow"
     61
     62
    5963// default window positioning
    6064static const float MIN_WIDTH = 400.0f;
    6165static const float MIN_HEIGHT = 336.0f;
     
    108112        fPlayFrames(0),
    109113        fLooping(false),
    110114        fSavePanel(NULL),
    111         fInitCheck(B_OK)
     115        fInitCheck(B_OK),
     116        fAppCatalog(NULL)
    112117{
    113118    fRoster = NULL;
    114119    fRecordButton = NULL;
     
    124129
    125130    CalcSizes(MIN_WIDTH, MIN_HEIGHT);
    126131
     132    be_locale->GetAppCatalog(&fAppCatalog);
     133   
     134    SetTitle(B_TRANSLATE("SoundRecorder"));
     135   
    127136    fInitCheck = InitWindow();
    128137    if (fInitCheck != B_OK) {
    129138        if (fInitCheck == B_NAME_NOT_FOUND)
    130             ErrorAlert("find default audio hardware", fInitCheck);
     139            ErrorAlert(B_TRANSLATE("Cannot find default audio hardware"),
     140                fInitCheck);
    131141        else
    132             ErrorAlert("connect to media server", fInitCheck);
     142            ErrorAlert(B_TRANSLATE("Cannot connect to media server"),
     143                fInitCheck);
    133144        PostMessage(B_QUIT_REQUESTED);
    134145    } else
    135146        Show();
     
    277288        //  Button for rewinding
    278289        buttonRect = BRect(BPoint(0,0), kSkipButtonSize);
    279290        buttonRect.OffsetTo(background->Bounds().LeftBottom() - BPoint(-7, 25));
    280         fRewindButton = new TransportButton(buttonRect, "Rewind",
     291        fRewindButton = new TransportButton(buttonRect, B_TRANSLATE("Rewind"),
    281292            kSkipBackBitmapBits, kPressedSkipBackBitmapBits,
    282293            kDisabledSkipBackBitmapBits, new BMessage(REWIND));
    283294        background->AddChild(fRewindButton);
     
    285296        //  Button for stopping recording or playback
    286297        buttonRect = BRect(BPoint(0,0), kStopButtonSize);
    287298        buttonRect.OffsetTo(background->Bounds().LeftBottom() - BPoint(-48, 25));
    288         fStopButton = new TransportButton(buttonRect, "Stop",
     299        fStopButton = new TransportButton(buttonRect, B_TRANSLATE("Stop"),
    289300            kStopButtonBitmapBits, kPressedStopButtonBitmapBits,
    290301            kDisabledStopButtonBitmapBits, new BMessage(STOP));
    291302        background->AddChild(fStopButton);
     
    293304        //  Button for starting playback of selected sound
    294305        BRect playRect(BPoint(0,0), kPlayButtonSize);
    295306        playRect.OffsetTo(background->Bounds().LeftBottom() - BPoint(-82, 25));
    296         fPlayButton = new PlayPauseButton(playRect, "Play",
     307        fPlayButton = new PlayPauseButton(playRect, B_TRANSLATE("Play"),
    297308            new BMessage(PLAY), new BMessage(PLAY_PERIOD), ' ', 0);
    298309        background->AddChild(fPlayButton);
    299310
    300311        //  Button for forwarding
    301312        buttonRect = BRect(BPoint(0,0), kSkipButtonSize);
    302313        buttonRect.OffsetTo(background->Bounds().LeftBottom() - BPoint(-133, 25));
    303         fForwardButton = new TransportButton(buttonRect, "Forward",
     314        fForwardButton = new TransportButton(buttonRect, B_TRANSLATE("Forward"),
    304315            kSkipForwardBitmapBits, kPressedSkipForwardBitmapBits,
    305316            kDisabledSkipForwardBitmapBits, new BMessage(FORWARD));
    306317        background->AddChild(fForwardButton);
     
    308319        //  Button to start recording (or waiting for sound)
    309320        buttonRect = BRect(BPoint(0,0), kRecordButtonSize);
    310321        buttonRect.OffsetTo(background->Bounds().LeftBottom() - BPoint(-174, 25));
    311         fRecordButton = new RecordButton(buttonRect, "Record",
     322        fRecordButton = new RecordButton(buttonRect, B_TRANSLATE("Record"),
    312323            new BMessage(RECORD), new BMessage(RECORD_PERIOD));
    313324        background->AddChild(fRecordButton);
    314325
    315326        //  Button for saving selected sound
    316327        buttonRect = BRect(BPoint(0,0), kDiskButtonSize);
    317328        buttonRect.OffsetTo(background->Bounds().LeftBottom() - BPoint(-250, 21));
    318         fSaveButton = new TransportButton(buttonRect, "Save",
     329        fSaveButton = new TransportButton(buttonRect, B_TRANSLATE("Save"),
    319330            kDiskButtonBitmapsBits, kPressedDiskButtonBitmapsBits,
    320331            kDisabledDiskButtonBitmapsBits, new BMessage(SAVE));
    321332        fSaveButton->SetResizingMode(B_FOLLOW_RIGHT | B_FOLLOW_TOP);
     
    324335        //  Button Loop
    325336        buttonRect = BRect(BPoint(0,0), kArrowSize);
    326337        buttonRect.OffsetTo(background->Bounds().RightBottom() - BPoint(23, 48));
    327         fLoopButton = new DrawButton(buttonRect, "Loop",
     338        fLoopButton = new DrawButton(buttonRect, B_TRANSLATE("Loop"),
    328339            kLoopArrowBits, kArrowBits, new BMessage(LOOP));
    329340        fLoopButton->SetResizingMode(B_FOLLOW_RIGHT | B_FOLLOW_TOP);
    330341        fLoopButton->SetTarget(this);
     
    366377        r.top += 4;
    367378        r.right -= B_V_SCROLL_BAR_WIDTH;
    368379        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);
    370382        fSoundList->SetSelectionMessage(new BMessage(SOUND_SELECTED));
    371383        fSoundList->SetViewColor(216, 216, 216);
    372384        BScrollView *scroller = new BScrollView("scroller", fSoundList,
     
    379391        r.InsetBy(10, 8);
    380392        r.top -= 1;
    381393        fFileInfoBox = new BBox(r, "fileinfo", B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
    382         fFileInfoBox->SetLabel("File info");
     394        fFileInfoBox->SetLabel(B_TRANSLATE("File info"));
    383395
    384396        r = fFileInfoBox->Bounds();
    385397        r.left = 8;
    386398        r.top = 13;
    387399        r.bottom = r.top + 15;
    388400        r.right -= 10;
    389         fFilename = new BStringView(r, "filename", "File name:");
     401        fFilename = new BStringView(r, "filename", B_TRANSLATE("File name:"));
    390402        fFileInfoBox->AddChild(fFilename);
    391403        r.top += 13;
    392404        r.bottom = r.top + 15;
    393         fFormat = new BStringView(r, "format", "Format:");
     405        fFormat = new BStringView(r, "format", B_TRANSLATE("Format:"));
    394406        fFileInfoBox->AddChild(fFormat);
    395407        r.top += 13;
    396408        r.bottom = r.top + 15;
    397         fCompression = new BStringView(r, "compression", "Compression:");
     409        fCompression = new BStringView(r, "compression",
     410            B_TRANSLATE("Compression:"));
    398411        fFileInfoBox->AddChild(fCompression);
    399412        r.top += 13;
    400413        r.bottom = r.top + 15;
    401         fChannels = new BStringView(r, "channels", "Channels:");
     414        fChannels = new BStringView(r, "channels", B_TRANSLATE("Channels:"));
    402415        fFileInfoBox->AddChild(fChannels);
    403416        r.top += 13;
    404417        r.bottom = r.top + 15;
    405         fSampleSize = new BStringView(r, "samplesize", "Sample size:");
     418        fSampleSize = new BStringView(r, "samplesize",
     419            B_TRANSLATE("Sample size:"));
    406420        fFileInfoBox->AddChild(fSampleSize);
    407421        r.top += 13;
    408422        r.bottom = r.top + 15;
    409         fSampleRate = new BStringView(r, "samplerate", "Sample rate:");
     423        fSampleRate = new BStringView(r, "samplerate",
     424            B_TRANSLATE("Sample rate:"));
    410425        fFileInfoBox->AddChild(fSampleRate);
    411426        r.top += 13;
    412427        r.bottom = r.top + 15;
    413         fDuration = new BStringView(r, "duration", "Duration:");
     428        fDuration = new BStringView(r, "duration", B_TRANSLATE("Duration:"));
    414429        fFileInfoBox->AddChild(fDuration);
    415430
    416431        //  Input selection lists all available physical inputs that produce
    417432        //  buffers with B_MEDIA_RAW_AUDIO format data.
    418         popup = new BPopUpMenu("Input");
     433        popup = new BPopUpMenu(B_TRANSLATE("Input"));
    419434        const int maxInputCount = 64;
    420435        dormant_node_info dni[maxInputCount];
    421436
     
    456471        r.right = (r.left + r.right) / 2;
    457472        r.InsetBy(10,10);
    458473        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);
    461476        fBottomBox->AddChild(fInputField);
    462477
    463478        fBottomBox->AddChild(fFileInfoBox);
     
    624639    //  Create a file with a temporary name
    625640    status_t err = NewTempName(name);
    626641    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);
    628644        return;
    629645    }
    630646    //  Find the file so we can refer to it later
    631647    err = fTempDir.FindEntry(name, &fRecEntry);
    632648    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);
    634651        return;
    635652    }
    636653    err = fRecFile.SetTo(&fTempDir, name, O_RDWR);
    637654    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);
    639657        fRecEntry.Unset();
    640658        return;
    641659    }
    642660    //  Reserve space on disk (creates fewer fragments)
    643661    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));
    646665    if (err < B_OK) {
    647         ErrorAlert("record a sound that long", err);
     666        ErrorAlert(B_TRANSLATE("Cannot record a sound that long"), err);
    648667        fRecEntry.Remove();
    649668        fRecEntry.Unset();
    650669        return;
     
    656675    //  Hook up input
    657676    err = MakeRecordConnection(fAudioInputNode);
    658677    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);
    660680        fRecEntry.Remove();
    661681        fRecEntry.Unset();
    662682        return;
     
    692712    fPlayButton->SetPlaying();
    693713
    694714    if (!fPlayTrack) {
    695         ErrorAlert("get the file to play", B_ERROR);
     715        ErrorAlert(B_TRANSLATE("Cannot get the file to play"), B_ERROR);
    696716        return;
    697717    }
    698718
     
    702722    fPlayFrame = fPlayTrack->CurrentFrame();
    703723
    704724    // 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");
    706727    status_t err = fPlayer->InitCheck();
    707728    if (err < B_OK) {
    708729        return;
     
    830851        return;
    831852    status_t err = UpdatePlayFile(pItem, true);
    832853    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"),
    834855            err == B_MEDIA_NO_HANDLER ? B_OK : err);
    835856        RemoveCurrentSoundItem();
    836857    }
     
    913934        return err;
    914935    }
    915936
    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);
    918941    if (err < B_OK) {
    919942        CONNECT((stderr, "RecorderWindow::MakeRecordConnection():"
    920943            " failed to connect sound recorder to audio input node.\n"));
     
    9781001        fRecFile.Seek(0, SEEK_SET);
    9791002        fRecFile.Write(&header, sizeof(header));
    9801003
    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.
    9821006        AddSoundItem(fRecEntry, true);
    9831007    }
    9841008    else {
     
    10371061}
    10381062
    10391063#ifndef __HAIKU__
    1040 extern "C" status_t DecodedFormat__11BMediaTrackP12media_format(BMediaTrack *self, media_format *inout_format);
     1064extern "C" status_t DecodedFormat__11BMediaTrackP12media_format(
     1065    BMediaTrack *self, media_format *inout_format);
    10411066#endif
    10421067
    10431068
     
    10931118    if (!updateDisplay)
    10941119        return B_OK;
    10951120
    1096     BString filename = "File name: ";
     1121    BString filename = B_TRANSLATE("File name: ");
    10971122    filename << ref.name;
    10981123    fFilename->SetText(filename.String());
    10991124
    1100     BString format = "Format: ";
     1125    BString format = B_TRANSLATE("Format: ");
    11011126    media_file_format file_format;
    11021127    if (fPlayFile->GetFileFormatInfo(&file_format) == B_OK)
    11031128        format << file_format.short_name;
    1104     BString compression = "Compression: ";
     1129    BString compression = B_TRANSLATE("Compression: ");
    11051130    media_codec_info codec_info;
    11061131    if (fPlayTrack->GetCodecInfo(&codec_info) == B_OK) {
    11071132        if (strcmp(codec_info.short_name, "raw")==0)
    1108             compression << "None";
     1133            compression << B_TRANSLATE("None");
    11091134        else
    11101135            compression << codec_info.short_name;
    11111136    }
    1112     BString channels = "Channels: ";
     1137    BString channels = B_TRANSLATE("Channels: ");
    11131138    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: ");
    11171143    samplerate << (int)fPlayFormat.u.raw_audio.frame_rate;
    1118     BString durationString = "Duration: ";
     1144    BString durationString = B_TRANSLATE("Duration: ");
    11191145    bigtime_t duration = fPlayTrack->Duration();
    1120     durationString << (float)(duration / 1000000.0) << " seconds";
     1146    durationString << (float)(duration / 1000000.0) << B_TRANSLATE(" seconds");
    11211147
    11221148    fFormat->SetText(format.String());
    11231149    fCompression->SetText(compression.String());
     
    11401166{
    11411167    char msg[300];
    11421168    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);
    11441170    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();
    11471173}
    11481174
    11491175
     
    13021328    }
    13031329
    13041330    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();
    13071334    else if (countGood > 0) {
    13081335        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();
    13121340        fSoundList->Select(fSoundList->CountItems() - 1);
    13131341    }
    13141342}
     
    13321360                bigtime_t start = fTrackSlider->LeftTime();
    13331361               
    13341362                // write data
    1335                 bigtime_t diffTime = fTrackSlider->RightTime() - fTrackSlider->LeftTime();
     1363                bigtime_t diffTime = fTrackSlider->RightTime()
     1364                    - fTrackSlider->LeftTime();
    13361365                int64 framesToWrite = (int64) (diffTime
    13371366                    * fPlayFormat.u.raw_audio.frame_rate / 1000000LL);
    13381367                int32 frameSize = (fPlayFormat.u.raw_audio.format & 0xf)
     
    13401369
    13411370                wave_struct header;
    13421371                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;
    13441374                header.riff.wave_id = FOURCC('W','A','V','E');
    13451375                header.format_chunk.fourcc = FOURCC('f','m','t',' ');
    13461376                header.format_chunk.len = sizeof(header.format);
    13471377                header.format.format_tag = 1;
    13481378                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
    13511383                    * fPlayFormat.u.raw_audio.channel_count
    13521384                    * (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;
    13541387                header.format.block_align = frameSize;
    13551388                header.data_chunk.fourcc = FOURCC('d','a','t','a');
    13561389                header.data_chunk.len = frameSize * framesToWrite;
  • src/apps/soundrecorder/UpDownButton.cpp

     
    22 * Copyright 2005, Jérôme Duval. All rights reserved.
    33 * Distributed under the terms of the MIT License.
    44 *
    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)
    67 */
    78#include "UpDownButton.h"
    89#include "icon_button.h"
     
    1314{
    1415    BRect rect = BRect(0, 0, kUpDownButtonWidth - 1, kUpDownButtonHeight - 1);
    1516    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);
    1719    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);
    1922    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);
    2125}
    2226
    2327
  • src/apps/soundrecorder/DrawButton.cpp

     
    88#include "DrawButton.h"
    99#include "DrawingTidbits.h"
    1010
    11 DrawButton::DrawButton(BRect frame, const char *name, const unsigned char *on, const unsigned char *off,
    12                         BMessage *msg, int32 resize, int32 flags)
     11DrawButton::DrawButton(BRect frame, const char *name, const unsigned char *on,
     12    const unsigned char *off, BMessage *msg, int32 resize, int32 flags)
    1313    : BControl(frame, name, "", msg, resize, flags | B_WILL_DRAW),
    1414        fOn(frame, B_CMAP8),
    1515        fOff(frame, B_CMAP8),