2 * Copyright 2005, Jérôme Duval. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Inspired by SoundCapture from Be newsletter (Media Kit Basics: Consumers and Producers)
7 #ifndef RECORDERWINDOW_H
8 #define RECORDERWINDOW_H
12 #include <Directory.h>
15 #include <FilePanel.h>
17 #include <MediaFile.h>
18 #include <MediaNode.h>
19 #include <MediaRecorder.h>
20 #include <MediaTrack.h>
21 #include <SoundPlayer.h>
24 #include "DrawButton.h"
25 #include "ScopeView.h"
26 #include "SoundListView.h"
27 #include "TransportButton.h"
28 #include "TrackSlider.h"
29 #include "UpDownButton.h"
30 #include "VolumeSlider.h"
45 class RecorderWindow
: public BWindow
{
48 virtual ~RecorderWindow();
52 virtual bool QuitRequested();
53 virtual void MessageReceived(BMessage
* message
);
56 RECORD
= 'cw00', // command messages
64 INPUT_SELECTED
= 'cW00', // control messages
74 void AddSoundItem(const BEntry
& entry
, bool temp
= false);
76 void RemoveCurrentSoundItem();
79 BMediaRoster
* fRoster
;
81 ScopeView
*fScopeView
;
82 RecordButton
* fRecordButton
;
83 PlayPauseButton
* fPlayButton
;
84 TransportButton
* fStopButton
;
85 TransportButton
* fRewindButton
;
86 TransportButton
* fForwardButton
;
87 TransportButton
* fSaveButton
;
88 DrawButton
* fLoopButton
;
89 VolumeSlider
*fVolumeSlider
;
90 TrackSlider
*fTrackSlider
;
91 UpDownButton
* fUpDownButton
;
92 BMenuField
* fInputField
;
93 BMediaRecorder
* fRecorder
;
94 BSoundPlayer
* fPlayer
;
96 bool fExternalConnection
;
97 SoundListView
* fSoundList
;
101 float fDeployedHeight
;
105 BStringView
*fFilename
;
106 BStringView
*fFormat
;
107 BStringView
*fCompression
;
108 BStringView
*fChannels
;
109 BStringView
*fSampleSize
;
110 BStringView
*fSampleRate
;
111 BStringView
*fDuration
;
118 BtnState fButtonState
;
121 media_format fRecordFormat
;
126 media_node fAudioInputNode
;
128 BMediaFile
*fPlayFile
;
129 media_format fPlayFormat
;
130 BMediaTrack
*fPlayTrack
;
137 media_node fAudioMixerNode
;
139 BFilePanel
*fSavePanel
;
142 status_t
InitWindow();
144 void Record(BMessage
* message
);
145 void Play(BMessage
* message
);
146 void Stop(BMessage
* message
);
147 void Save(BMessage
* message
);
148 void DoSave(BMessage
* message
);
149 void Input(BMessage
* message
);
150 void Length(BMessage
* message
);
151 void Selected(BMessage
* message
);
153 status_t
MakeRecordConnection(const media_node
& input
);
154 status_t
BreakRecordConnection();
155 status_t
StopRecording();
157 status_t
MakePlayConnection(const media_multi_audio_format
& format
);
158 status_t
BreakPlayConnection();
159 status_t
StopPlaying();
161 status_t
NewTempName(char * buffer
);
162 void CalcSizes(float min_width
, float min_height
);
163 void SetButtonState(BtnState state
);
164 void UpdateButtons();
165 status_t
UpdatePlayFile(SoundListItem
*item
, bool updateDisplay
= false);
166 void ErrorAlert(const char * action
, status_t err
);
168 static void RecordFile(void * cookie
, bigtime_t timestamp
, void * data
, size_t size
, const media_format
& format
);
169 static void NotifyRecordFile(void * cookie
, BMediaRecorder::notification code
, ...);
171 static void PlayFile(void * cookie
, void * data
, size_t size
, const media_raw_audio_format
& format
);
172 static void NotifyPlayFile(void * cookie
, BSoundPlayer::sound_player_notification code
, ...);
174 void RefsReceived(BMessage
*msg
);
175 void CopyTarget(BMessage
*msg
);
178 #endif /* RECORDERWINDOW_H */