Commit Graph

39 Commits

Author SHA1 Message Date
Bill Somerville
7b000afb78
Ignore audio i/p underrun error until macOS behaviour understood 2020-09-27 17:25:58 +01:00
Bill Somerville
e8808ebc54
Remove unnecessary stop of the input audio stream after error notifications 2020-09-26 21:07:35 +01:00
Bill Somerville
f12f481955
Remove unused member variable that breaks the Raspberry Pi build 2020-09-26 17:47:38 +01:00
Bill Somerville
542ffe8311
Improve audio device handling and error recovery
where possible  audio devices that  disappear are not  forgotten until
the user selects another device, this should allow temporarily missing
devices or forgetting  to switch on devices before  starting WSJT-X to
be  handled more  cleanly. If  all else  fails, visiting  the Settings
dialog and  clicking OK should  get things  going again. Note  that we
still  do not  have  a  reliable way  of  detecting  failed audio  out
devices, in that  case selecting another device and  then returning to
the original should work.

Enumerating  audio devices  is expensive  and on  Linux may  take many
seconds per  device. To avoid  lengthy blocking behaviour until  it is
absolutely necessary,  audio devices are  not enumerated until  one of
the "Settings->Audio" device drop-down lists is opened. Elsewhere when
devices  must be  discovered  the  enumeration stops  as  soon as  the
configured device is  discovered. A status bar message  is posted when
audio devices are being enumerated as a reminder that the UI may block
while this is happening.

The message box warning about  unaccounted-for input audio samples now
only triggers when  >5 seconds of audio appears to  be missing or over
provided. Hopefully this will make the warning less annoying for those
that are  using audio sources  with high and/or variable  latencies. A
status  bar message  is still  posted for  any amount  of audio  input
samples  unaccounted for  >1/5 second,  this message  appearing a  lot
should be considered as notification that  there is a problem with the
audio sub-system, system load is  too high, or time synchronization is
stepping the PC clock rather  than adjusting the frequency to maintain
monotonic clock ticks.
2020-09-20 18:20:16 +01:00
Bill Somerville
66e887b2f9
Merge branch 'develop' into feat-dropped-frames 2020-09-12 00:19:04 +01:00
Joe Taylor
6ff8459ea9 Add a book-keeping file useful in QtCreator. 2020-09-07 18:40:26 -04:00
Bill Somerville
d1fa08ab78
Handle 24hr wrap of QAudioInput::elapsedUSecs() on Linux & Windows 2020-08-22 18:09:51 +01:00
Bill Somerville
65f994ce90
Improved audio stream error handling 2020-08-16 00:55:29 +01:00
Bill Somerville
11abe7c60f
Cosmetic reformating 2020-08-13 10:30:49 +01:00
Bill Somerville
e69226b29a
Avoid enumerating audio devices until absolutely necessary
Enumerating  audio  devices with  QAudioDeviceInfo::availableDevices()
takes  a  long  time  on  Linux  with  pulseaudio.  This  change  only
enumerates  up  to  the  selected device  when  configuring  and  only
enumerates the whole list when the Settings->Audio tab is current.

This change also warns  with a message box when Tx  is started with no
audio output device configured.
2020-08-12 02:33:15 +01:00
Bill Somerville
4f68dfda40
Only tune audio buffer sizes on Windows 2020-08-11 14:27:46 +01:00
Bill Somerville
0cf14dfcc9
Remove user adjustable audio buffer sizes from Settings
Fixed buffer sizes are  used. Rx use s 3456 x 1st  downsample rate x 5
audio  frames  of  buffer  space.  On Windows  this  means  that  each
chunk (periodSize())  delivered from the  audio stream is  our initial
DSP processing chunk size, thus  matching audio buffer latency exactly
with WSJT-X's  own front  end latency. This  should result  in optimal
resilience to high system loads that might starve the soundcard ADC of
buffers to fill and case dropped audio frames.

For Tx  a buffer sufficient for  1 s of  audio is used at  present, on
Windows  the period  size will  be  set to  1/40 of  that which  gives
reasonably low latency  and plenty of resilience to  high system loads
that might  starve the soundcard DAC  of audio frames to  render. Note
that a 1 s  buffer will make the "Pwr" slider slow  to respond, we may
have to reduce the Tx audio buffer size if this is seen as a problem.
2020-08-11 13:48:01 +01:00
Bill Somerville
ecde374cee
Trying a fixed audio input buffer size 2020-08-10 11:01:38 +01:00
Bill Somerville
2e413713a3
Tidy dropped frame status bar message 2020-08-08 19:40:42 +01:00
Bill Somerville
02e19b687f
Status message to report approximate # of dropped Rx audio frames
This is  a first cut  at this to  evaluate buffer size  adjustments on
supported platforms. A final version might limit status bar reports to
>1000 dropped frames or similar.
2020-08-08 17:12:48 +01:00
Bill Somerville
6ea62d9476
Remove default audio devices from audio configuration
This enforces  an audio input device  in the settings dialog  since we
can't do anything  without an input device. A nil  audio output device
is allowed with a warning.
2020-08-08 16:57:51 +01:00
Bill Somerville
a0ceace5b4
User configurable audio device buffer sizes
Adjusting these may help with  audio drop-outs, particularly on slower
CPU systems or heavily loaded systems. Smaller buffer sizes leave less
margin for  process interruptions,  larger sizes waste  resources that
could impact other processes.
2020-08-08 16:25:14 +01:00
Bill Somerville
9c22b5c3ed
Qt v5.15 compatibility 2020-06-13 16:04:41 +01:00
Bill Somerville
2a3e4c1e50
Merge branch 'feat-refactor' of bitbucket.org:g4wjs/wsjtx-refactor into feat-refactor 2019-07-03 00:59:15 +01:00
Bill Somerville
34bfebf1bd
Squash some warnings 2019-07-03 00:58:27 +01:00
Bill Somerville
ccac8c4f6e
Squash a couple of warnings 2019-07-03 00:03:02 +01:00
sirhc808
1f57ba5fec improve physical structure 2019-07-02 12:45:05 -05:00
Bill Somerville
350391d66e AAdded audio o/p category to playback options 2019-05-11 16:43:48 +01:00
Bill Somerville
c393740b0a Fix an off by error 2019-05-11 01:57:56 +01:00
Bill Somerville
8d6c7649e0 Repaired a defect in the calculation of delay before starting audio streams 2019-05-10 20:31:16 +01:00
Bill Somerville
62f9b32758 Added playback to record_time_signal tool
The tool may be started with either '-o <file-path>' to record or with
'-i  <file-path>',  where  file-path  is an  existing  .WAV  file,  to
playback  audio. Audio  output devices  may  be listed  with the  '-O'
option  and selected  by index  number using  the '-P  <device-index>'
option. No format conversions are done for playback by the tool so the
output device  must support  the format  of the  input .WAV  file. The
playback duration is the duration of the input .WAV file.

The tool '-s <start-second-in-minute>' option is now optional, without
it recording  or playback  starts immediately. So  to playback  a .WAV
file:

    $ record_time_signal -i wwv.wav

To play back the same file stating at second 55 in the minute:

   $ record_time_signal -i wwv.wav -s 55

Use the '-h' option for more help.
2019-05-10 19:38:04 +01:00
Bill Somerville
3a3af42cc6 Tool to exercise QAudioInput
The tool record_time_signal is designed  to measure the performance of
QAudioInput. The  intended use  is to  record a  short period  of live
audio from  an on-air time  signal of  known good quaility,  the basic
required parameters  are an  audio input device,  an output  file name
(.WAV), a start second in a minute,  and a duration in seconds. So for
example to record  the time signal ticks  and fast data at  the top of
the minute:

    $ record_time_signal -o wwv.wav -s 55 -d 15

will record  15s of  audio at  48000Hz sample  rate, stereo,  from the
default audio  input device, starting  at second  55. This will  use a
separate timer  to stop  the recording  which is  likely to  leave the
output file a little short due  to buffer latency. The buffer size can
be adjusted using the '-b <buffered-frames>' option.

The tool  also supoorts  a different mechanism  to time  the recording
which uses the audio progress via  a notify signal. This should ensure
at least  the requested  duration is recorded  The shorter  the notify
interval  the  closer teh  final  size  shoould  be to  the  requested
duration.  Use the  '-d  <interval-ms>' option  to  adjust the  notify
interval.

    $ record_time_signal -o wwv.wav -s 55 -d 15 -n 100

Non-default audio devices can be selected, use the '-I' option to list
the available input  devices with an index number that  can be used to
select the device using the 'R <device-number>' option.

Other options are available, use '-h' for details.
2019-05-10 17:27:52 +01:00
Bill Somerville
0b03ad4c09 Fix a potential crashes in BWF (WAV) file writes 2018-11-11 19:05:15 +00:00
Bill Somerville
8e43af11e5 Fix numerous memory leaks and uses of uninitialized variables
These were discovered when running under teh valgrind MemCheck tool. I
have also  checked in a suppressions  file (wsjtx-valgrind.linux.supp)
suitable for use on Linux when running the valgrind MemCheck tool.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6755 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
2016-06-10 15:54:16 +00:00
Bill Somerville
4a33a696ba Enhanced error reporting for BWF (WAV) files
The BWFFile class  correctly indicates errors like  file access issues
and problems reading or writing headers using the BWFFile::error() and
BWFFile::errorString() operations.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6751 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
2016-06-09 23:39:33 +00:00
Bill Somerville
64f1de08c8 Squash another warning
git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6596 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
2016-04-07 00:02:24 +00:00
Bill Somerville
720412ff5a Squash some more warnings
git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6595 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
2016-04-06 23:30:32 +00:00
Bill Somerville
e565e1796a Clean up some compiler warnings
git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6591 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
2016-04-06 22:37:22 +00:00
Bill Somerville
a3c1c768ef Fix some compiler warnings and error
Clang++ detected some warnings that g++ did not.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6409 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
2016-01-20 20:32:30 +00:00
Bill Somerville
0f59c63ea6 Fix a regression in WAV file writing from r6383
WAV files were written with an incorrect fomat chunk average bytes per
second field.  This only effects  a few  media players like  WMP, most
ignore this field.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6405 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
2016-01-19 19:06:12 +00:00
Bill Somerville
9301347f8a Better naming WavFile ->BWFFile
Broadcast  Wave  Format is  a  backwards  compatible superset  of  teh
Microsoft WAV file  format that has been implemented in  teh hope that
Windows File Explorer might show the WAV file metadta, as it turns out
that is not the case but as it's done anyway.

It appears to be  impossible to write a WAV file  such that MS Windows
File Explorer shows any metadata so  unless we adopt FLAC format audio
files we will have to show metadata with our own software :(

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6384 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
2016-01-11 15:00:53 +00:00
Bill Somerville
4e6de783b0 Use new WAV file class (BWFFile) read and write WAV files
Saved WAV files now contain some useful metadata.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6383 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
2016-01-11 15:00:43 +00:00
Bill Somerville
7b7ef610b5 Fix integer size and sign issues
WAV files use 32-bit sizes so casts are needed on 64-bit files systems

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6340 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
2016-01-02 19:10:16 +00:00
Bill Somerville
58aacc590e Class to read and write WAV format files
git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6337 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
2016-01-02 17:19:49 +00:00