Audacity  3.0.3
Classes | Enumerations | Functions
ImportRaw.cpp File Reference

Functions for guessing audio type and attempting to read from unknown sample audio data. Implements ImportRawDialog. More...

#include "ImportRaw.h"
#include "ImportPlugin.h"
#include "AudioIOBase.h"
#include "../FileFormats.h"
#include "Prefs.h"
#include "ProjectRate.h"
#include "../SelectFile.h"
#include "../ShuttleGui.h"
#include "UserException.h"
#include "../WaveTrack.h"
#include "../widgets/ProgressDialog.h"
#include <cmath>
#include <cstdio>
#include <stdint.h>
#include <vector>
#include <wx/crt.h>
#include <wx/defs.h>
#include <wx/button.h>
#include <wx/choice.h>
#include <wx/combobox.h>
#include <wx/filename.h>
#include <wx/intl.h>
#include <wx/panel.h>
#include <wx/sizer.h>
#include <wx/stattext.h>
#include <wx/textctrl.h>
#include <wx/timer.h>
#include "FormatClassifier.h"
#include "sndfile.h"
Include dependency graph for ImportRaw.cpp:

Go to the source code of this file.

Classes

class  ImportRawDialog
 ImportRawDialog prompts you with options such as endianness and sample size to help you importing data of an unknown format. More...
 

Enumerations

enum  {
  IndicatorSmallWidth = 9, IndicatorMediumWidth = 13, IndicatorOffset = 1, TopMargin = 1,
  BottomMargin = 2, LeftMargin = 1, RightMargin = 1, ID_QUIT_AUDACITY = 10000,
  ID_DISCARD_SELECTED, ID_RECOVER_SELECTED, ID_SKIP, ID_FILE_LIST,
  AddButtonID = 10000, RemoveButtonID, RenameButtonID, RestoreButtonID,
  ImportButtonID, ExportButtonID, SaveButtonID, DefaultsButtonID,
  InsertButtonID, EditButtonID, DeleteButtonID, UpButtonID,
  DownButtonID, ApplyToProjectButtonID = ApplyToProjectID, ApplyToFilesButtonID = ApplyToFilesID, RunID = 1000,
  BSaveID, ClearID, StaticTextID, BlockSizeID,
  DataSizeID, NumEditsID, RandSeedID, kCommands,
  kMenus, kPreferences, kTracks, kClips,
  kEnvelopes, kLabels, kBoxes, nTypes,
  kJson, kLisp, kBrief, nFormats,
  FileListID = 6000, CopySelectedFilesButtonID, CopyNamesToClipboardID, FutureActionChoiceID,
  ID_Amp = 10000, ID_Peak, ID_Clip, ID_Bass = 10000,
  ID_Treble, ID_Gain, ID_Link, ID_PercentChange = 10000,
  ID_Multiplier, ID_FromVinyl, ID_ToVinyl, ID_ToLength,
  ID_Thresh = 10000, ID_Width, ID_Threshold = 10000, ID_NoiseFloor,
  ID_Ratio, ID_Attack, ID_Decay, ID_BUTTON_USECURRENTF = 10001,
  ID_BUTTON_USECURRENTB, ID_BUTTON_EXPORT, ID_BUTTON_RESET, ID_FOREGROUNDSTART_T,
  ID_FOREGROUNDEND_T, ID_BACKGROUNDSTART_T, ID_BACKGROUNDEND_T, ID_FOREGROUNDDB_TEXT,
  ID_BACKGROUNDDB_TEXT, ID_RESULTS_TEXT, ID_RESULTSDB_TEXT, ID_Sequence,
  ID_Amplitude, ID_Duration, ID_DutyCycle, ID_Length = 10000,
  ID_dBMax, ID_dBMin, ID_Clear, ID_Invert,
  ID_Mode, ID_Draw, ID_Graphic, ID_Interp,
  ID_Linear, ID_Grid, ID_Curve, ID_Manage,
  ID_Delete, ID_Slider, ID_Duration = 20000, ID_Toggles = 21000,
  ID_Sliders = 22000, ID_Texts = 23000, ID_Duration = 10000, ID_Triggers = 11000,
  ID_Toggles = 12000, ID_Sliders = 13000, ID_Choices = 14000, ID_Texts = 15000,
  ID_TIMER = 20000, ID_BUTTON_GETPROFILE = 10001, ID_RADIOBUTTON_KEEPSIGNAL, ID_RADIOBUTTON_RESIDUE,
  ID_GAIN_SLIDER, ID_GAIN_TEXT, ID_NEW_SENSITIVITY_SLIDER, ID_NEW_SENSITIVITY_TEXT,
  ID_FREQ_SLIDER, ID_FREQ_TEXT, END_OF_BASIC_SLIDERS, END_OF_SLIDERS = END_OF_BASIC_SLIDERS,
  FIRST_SLIDER = ID_GAIN_SLIDER, ID_BUTTON_GETPROFILE = 10001, ID_BUTTON_LEAVENOISE, ID_RADIOBUTTON_KEEPSIGNAL,
  ID_RADIOBUTTON_KEEPNOISE, ID_SENSITIVITY_SLIDER, ID_GAIN_SLIDER, ID_FREQ_SLIDER,
  ID_TIME_SLIDER, ID_SENSITIVITY_TEXT, ID_GAIN_TEXT, ID_FREQ_TEXT,
  ID_TIME_TEXT, ID_Editor = 10000, ID_Load, ID_Save,
  ID_Slider = 11000, ID_Choice = 13000, ID_FILE = 15000, ID_Stages = 10000,
  ID_DryWet, ID_Freq, ID_Phase, ID_Depth,
  ID_Feedback, ID_OutGain, ID_RoomSize = 10000, ID_PreDelay,
  ID_Reverberance, ID_HfDamping, ID_ToneLow, ID_ToneHigh,
  ID_WetGain, ID_DryGain, ID_StereoWidth, ID_WetOnly,
  SBSMSOutBlockSize = 512, ID_FilterPanel = 10000, ID_dBMax, ID_dBMin,
  ID_Type, ID_SubType, ID_Order, ID_Ripple,
  ID_Cutoff, ID_StopbandRipple, ID_RatePercentChangeStart = 10000, ID_RatePercentChangeEnd,
  ID_PitchHalfStepsStart, ID_PitchHalfStepsEnd, ID_PitchPercentChangeStart, ID_PitchPercentChangeEnd,
  ID_Program = 10000, ID_Sliders = 11000, ID_Choices = 12000, ID_Texts = 13000,
  ID_Toggles = 14000, ID_Duration = 20000, ID_Sliders = 21000, ID_Freq = 10000,
  ID_Phase, ID_Depth, ID_Res, ID_FreqOfs,
  ID_OutGain, ID_MIXERPANEL = 10001, ID_SLIDER_CHANNEL, QUALITY_2 = 2,
  PRESET_INSANE = 0, PRESET_EXTREME = 1, PRESET_STANDARD = 2, PRESET_MEDIUM = 3,
  FormatID = 10001, OptionsID, DirID, CreateID,
  ChooseID, LabelID, FirstID, FirstFileNameID,
  TrackID, ByNameAndNumberID, ByNameID, ByNumberID,
  PrefixID, OverwriteID, FirstID = 7000, FreqZoomSliderID,
  FreqPanScrollerID, FreqExportButtonID, FreqAlgChoiceID, FreqSizeChoiceID,
  FreqFuncChoiceID, FreqAxisChoiceID, ReplotButtonID, GridOnOffID,
  ID_AVAIL = 1000, ID_FILESIZE, ID_TOTAL, ID_LEVELS,
  ID_DISCARD, ID_DISCARD_CLIPBOARD, ID_COMPACT, ChoiceID = 9000,
  PlayID, DetectID, ID_INSERTA = 11000, ID_INSERTB,
  ID_REMOVE, ID_IMPORT, ID_EXPORT, LoggerID_Save = wxID_HIGHEST + 1,
  LoggerID_Clear, LoggerID_Close, kID_RadioButton_BouncingBall = 10101, kID_RadioButton_Highlight,
  ID_BITMAPBUTTON_MUSICAL_INSTRUMENT = 13000, ID_SLIDER_PAN, ID_SLIDER_GAIN, ID_TOGGLEBUTTON_MUTE,
  ID_TOGGLEBUTTON_SOLO, kModuleDisabled = 0, kModuleEnabled = 1, kModuleAsk = 2,
  kModuleFailed = 3, kModuleNew = 4, STATE_Enabled, STATE_Disabled,
  STATE_New, STATE_COUNT, HostID = 10000, PlayID,
  RecordID, ChannelsID, ToolColumn, ActionColumn,
  ButtonsColumn, CommentColumn, UseCustomTrackNameID = 1000, ID_WINDOW_SIZE = 10001,
  ID_WINDOW_TYPE, ID_PADDING_SIZE, ID_SCALE, ID_ALGORITHM,
  ID_MINIMUM, ID_MAXIMUM, ID_GAIN, ID_RANGE,
  ID_FREQUENCY_GAIN, ID_COLOR_SCHEME, ID_SPECTRAL_SELECTION, ID_DEFAULTS,
  ID_DEFAULTS = 10001, ID_SCALE, ID_RANGE, FSCKstatus_CLOSE_REQ = 0x1,
  FSCKstatus_CHANGED = 0x2, FSCKstatus_SAVE_AUP = 0x4, SNAP_OFF, SNAP_NEAREST,
  SNAP_PRIOR, FirstID = 1000, HSBarID, VSBarID,
  NextID, FFT_SinCosBRTable, FFT_SinCosTableVBR16, FFT_SinCosTableBR16,
  FFT_FastMathBR16, FFT_FastMathBR24, IdMainWindowSmall = 19200, IdMainWindowLarge,
  IdDirectory, IdDirChoose, IdOneSec, IdTenSec,
  IdOneMin, IdFiveMin, IdOneHour, IdShortTracks,
  IdMedTracks, IdTallTracks, IdDelayCheckBox, IdCaptureFirst,
  IdCaptureEffects = IdCaptureFirst, IdCaptureScriptables, IdCapturePreferences, IdCaptureToolbars,
  IdAllDelayedEvents, IdCaptureWindowContents =IdAllDelayedEvents, IdCaptureFullWindow, IdCaptureWindowPlus,
  IdCaptureFullScreen, IdCaptureSelectionBar, IdCaptureSpectralSelection, IdCaptureTimer,
  IdCaptureTools, IdCaptureTransport, IdCaptureMixer, IdCaptureMeter,
  IdCapturePlayMeter, IdCaptureRecordMeter, IdCaptureEdit, IdCaptureDevice,
  IdCaptureTranscription, IdCaptureScrub, IdCaptureTrackPanel, IdCaptureRuler,
  IdCaptureTracks, IdCaptureFirstTrack, IdCaptureSecondTrack, IdCaptureLast = IdCaptureSecondTrack,
  IdLastDelayedEvent, IdToggleBackgroundBlue, IdToggleBackgroundWhite, eOkButton = 0x0001,
  eCancelButton = 0x0002, eYesButton = 0x0004, eNoButton = 0x0008, eHelpButton = 0x0010,
  ePreviewButton = 0x0020, eDebugButton = 0x0040, eSettingsButton = 0x0080, ePreviewDryButton = 0x0100,
  eApplyButton = 0x0200, eCloseButton = 0x0400, DontShowID =1000, ID_DATEPICKER_START = 10000,
  ID_TIMETEXT_START, ID_DATEPICKER_END, ID_TIMETEXT_END, ID_TIMETEXT_DURATION,
  ID_AUTOSAVEPATH_BUTTON, ID_AUTOSAVEPATH_TEXT, ID_AUTOEXPORTPATH_BUTTON, ID_AUTOEXPORTPATH_TEXT,
  ID_AUTOSAVE_CHECKBOX, ID_AUTOEXPORT_CHECKBOX, POST_TIMER_RECORD_STOPPED = -3, POST_TIMER_RECORD_CANCEL_WAIT,
  POST_TIMER_RECORD_CANCEL, POST_TIMER_RECORD_NOTHING = 0, POST_TIMER_RECORD_CLOSE, ETBCutID,
  ETBCopyID, ETBPasteID, ETBTrimID, ETBSilenceID,
  ETBUndoID, ETBRedoID, ETBZoomInID, ETBZoomOutID,
  ETBZoomSelID, ETBZoomFitID, ETBNumButtons, STBScrubID,
  STBSeekID, STBRulerID, STBNumButtons, STBFirstButton = STBScrubID,
  SelectionBarFirstID = 2700, RateID, SnapToID, OnMenuID,
  ChoiceID, StartTimeID, LengthTimeID, CenterTimeID,
  EndTimeID, AudioTimeID, TimeBarFirstID = 2800, AudioPositionID,
  ToolBarFloatMargin = 1, NoDockID = 0, TopDockID, BotDockID,
  DockCount = 2, TTB_PlaySpeed, TTB_PlaySpeedSlider, TTBNumButtons,
  @0::kTimerInterval = 50, kAffordancesAreaHeight = 18, kTopInset = 4, kTopMargin = kTopInset + kBorderThickness,
  kBottomMargin = kShadowThickness + kBorderThickness, kTrackSeparatorThickness = kBottomMargin + kTopMargin, kChannelSeparatorThickness = 1, OnSetFontID = 30000,
  OnCutSelectedTextID = 1, OnCopySelectedTextID, OnPasteSelectedTextID, OnDeleteSelectedLabelID,
  OnEditSelectedLabelID, OnUpOctaveID = 30000, OnDownOctaveID, OnZoomFitVerticalID = 20000,
  OnZoomResetID, OnZoomDiv2ID, OnZoomTimes2ID, OnZoomHalfWaveID,
  OnZoomInVerticalID, OnZoomOutVerticalID, OnZoomMaxID, OnUpOctaveID,
  OnDownOctaveID, reserveDisplays = 100, OnRate8ID = 30000, OnRate11ID,
  OnRate16ID, OnRate22ID, OnRate44ID, OnRate48ID,
  OnRate88ID, OnRate96ID, OnRate176ID, OnRate192ID,
  OnRate352ID, OnRate384ID, OnRateOtherID, On16BitID,
  On24BitID, OnFloatID, OnMultiViewID, OnSetDisplayId,
  lastDisplayId = (OnSetDisplayId + reserveDisplays - 1), OnChannelLeftID, OnChannelRightID, OnChannelMonoID,
  OnMergeStereoID, OnSwapChannelsID, OnSplitStereoID, OnSplitStereoMonoID,
  ChannelMenuID, FirstAttachedItemId, OnZoomFitVerticalID = 20000, OnZoomResetID,
  OnZoomDiv2ID, OnZoomTimes2ID, OnZoomHalfWaveID, OnZoomInVerticalID,
  OnZoomOutVerticalID, OnFirstWaveformScaleID, OnLastWaveformScaleID = OnFirstWaveformScaleID + 9, OnFirstSpectrumScaleID,
  OnLastSpectrumScaleID = OnFirstSpectrumScaleID + 19, OnTimeTrackLinID = 30000, OnTimeTrackLogID, OnTimeTrackLogIntID,
  OnSetTimeTrackRangeID, SELECTION_RESIZE_REGION = 3, FREQ_SNAP_DISTANCE = 10, OnSetNameID = 2000,
  OnMoveUpID, OnMoveDownID, OnMoveTopID, OnMoveBottomID,
  SCRUBBING_PIXEL_TOLERANCE = 10, kOneSecondCountdown = 1000 / ScrubPollInterval_ms, SELECTION_RESIZE_REGION = 3, FREQ_SNAP_DISTANCE = 10,
  ID_TIMER = wxID_HIGHEST + 1, DontShowID = wxID_HIGHEST + 1, kToggleButtonID = 5000, kTimerID,
  OnMeterUpdateID = 6000, OnMonitorID, OnPreferencesID, AV_FRAME_CROP_UNALIGNED = 1 << 0,
  AV_FRAME_CROP_UNALIGNED = 1 << 0, MAX_HFFT = 10, kVerticalPadding = 7, kBorderThickness = 1,
  kShadowThickness = 1, kLeftInset = 4, kRightInset = kLeftInset, kLeftMargin = kLeftInset + kBorderThickness,
  kRightMargin = kRightInset + kShadowThickness + kBorderThickness, kTrackInfoWidth = 100 - kLeftMargin, ID_AUTOLOAD = 20000, ID_AUTOWRAP,
  ID_FONT, ID_SPLITV, ID_SPLITH, ID_TOGGLECODE,
  ID_TOGGLEOUTPUT, ID_SMALLICONS, ID_LARGEICONS, ID_MATCH,
  ID_TOP, ID_UP, ID_PREVIOUS, ID_NEXT,
  ID_GO, ID_STOP, ID_SCRIPT, ID_OUTPUT
}
 

Functions

void ImportRaw (const AudacityProject &project, wxWindow *parent, const wxString &fileName, WaveTrackFactory *trackFactory, TrackHolders &outTracks)
 
static int getEndianChoice (int sfFormat)
 

Detailed Description

Functions for guessing audio type and attempting to read from unknown sample audio data. Implements ImportRawDialog.

Definition in file ImportRaw.cpp.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
IndicatorSmallWidth 
IndicatorMediumWidth 
IndicatorOffset 
TopMargin 
BottomMargin 
LeftMargin 
RightMargin 
ID_QUIT_AUDACITY 
ID_DISCARD_SELECTED 
ID_RECOVER_SELECTED 
ID_SKIP 
ID_FILE_LIST 
AddButtonID 
RemoveButtonID 
RenameButtonID 
RestoreButtonID 
ImportButtonID 
ExportButtonID 
SaveButtonID 
DefaultsButtonID 
InsertButtonID 
EditButtonID 
DeleteButtonID 
UpButtonID 
DownButtonID 
ApplyToProjectButtonID 
ApplyToFilesButtonID 
RunID 
BSaveID 
ClearID 
StaticTextID 
BlockSizeID 
DataSizeID 
NumEditsID 
RandSeedID 
kCommands 
kMenus 
kPreferences 
kTracks 
kClips 
kEnvelopes 
kLabels 
kBoxes 
nTypes 
kJson 
kLisp 
kBrief 
nFormats 
FileListID 
CopySelectedFilesButtonID 
CopyNamesToClipboardID 
FutureActionChoiceID 
ID_Amp 
ID_Peak 
ID_Clip 
ID_Bass 
ID_Treble 
ID_Gain 
ID_Link 
ID_PercentChange 
ID_Multiplier 
ID_FromVinyl 
ID_ToVinyl 
ID_ToLength 
ID_Thresh 
ID_Width 
ID_Threshold 
ID_NoiseFloor 
ID_Ratio 
ID_Attack 
ID_Decay 
ID_BUTTON_USECURRENTF 
ID_BUTTON_USECURRENTB 
ID_BUTTON_EXPORT 
ID_BUTTON_RESET 
ID_FOREGROUNDSTART_T 
ID_FOREGROUNDEND_T 
ID_BACKGROUNDSTART_T 
ID_BACKGROUNDEND_T 
ID_FOREGROUNDDB_TEXT 
ID_BACKGROUNDDB_TEXT 
ID_RESULTS_TEXT 
ID_RESULTSDB_TEXT 
ID_Sequence 
ID_Amplitude 
ID_Duration 
ID_DutyCycle 
ID_Length 
ID_dBMax 
ID_dBMin 
ID_Clear 
ID_Invert 
ID_Mode 
ID_Draw 
ID_Graphic 
ID_Interp 
ID_Linear 
ID_Grid 
ID_Curve 
ID_Manage 
ID_Delete 
ID_Slider 
ID_Duration 
ID_Toggles 
ID_Sliders 
ID_Texts 
ID_Duration 
ID_Triggers 
ID_Toggles 
ID_Sliders 
ID_Choices 
ID_Texts 
ID_TIMER 
ID_BUTTON_GETPROFILE 
ID_RADIOBUTTON_KEEPSIGNAL 
ID_RADIOBUTTON_RESIDUE 
ID_GAIN_SLIDER 
ID_GAIN_TEXT 
ID_NEW_SENSITIVITY_SLIDER 
ID_NEW_SENSITIVITY_TEXT 
ID_FREQ_SLIDER 
ID_FREQ_TEXT 
END_OF_BASIC_SLIDERS 
END_OF_SLIDERS 
FIRST_SLIDER 
ID_BUTTON_GETPROFILE 
ID_BUTTON_LEAVENOISE 
ID_RADIOBUTTON_KEEPSIGNAL 
ID_RADIOBUTTON_KEEPNOISE 
ID_SENSITIVITY_SLIDER 
ID_GAIN_SLIDER 
ID_FREQ_SLIDER 
ID_TIME_SLIDER 
ID_SENSITIVITY_TEXT 
ID_GAIN_TEXT 
ID_FREQ_TEXT 
ID_TIME_TEXT 
ID_Editor 
ID_Load 
ID_Save 
ID_Slider 
ID_Choice 
ID_FILE 
ID_Stages 
ID_DryWet 
ID_Freq 
ID_Phase 
ID_Depth 
ID_Feedback 
ID_OutGain 
ID_RoomSize 
ID_PreDelay 
ID_Reverberance 
ID_HfDamping 
ID_ToneLow 
ID_ToneHigh 
ID_WetGain 
ID_DryGain 
ID_StereoWidth 
ID_WetOnly 
SBSMSOutBlockSize 
ID_FilterPanel 
ID_dBMax 
ID_dBMin 
ID_Type 
ID_SubType 
ID_Order 
ID_Ripple 
ID_Cutoff 
ID_StopbandRipple 
ID_RatePercentChangeStart 
ID_RatePercentChangeEnd 
ID_PitchHalfStepsStart 
ID_PitchHalfStepsEnd 
ID_PitchPercentChangeStart 
ID_PitchPercentChangeEnd 
ID_Program 
ID_Sliders 
ID_Choices 
ID_Texts 
ID_Toggles 
ID_Duration 
ID_Sliders 
ID_Freq 
ID_Phase 
ID_Depth 
ID_Res 
ID_FreqOfs 
ID_OutGain 
ID_MIXERPANEL 
ID_SLIDER_CHANNEL 
QUALITY_2 
PRESET_INSANE 
PRESET_EXTREME 
PRESET_STANDARD 
PRESET_MEDIUM 
FormatID 
OptionsID 
DirID 
CreateID 
ChooseID 
LabelID 
FirstID 
FirstFileNameID 
TrackID 
ByNameAndNumberID 
ByNameID 
ByNumberID 
PrefixID 
OverwriteID 
FirstID 
FreqZoomSliderID 
FreqPanScrollerID 
FreqExportButtonID 
FreqAlgChoiceID 
FreqSizeChoiceID 
FreqFuncChoiceID 
FreqAxisChoiceID 
ReplotButtonID 
GridOnOffID 
ID_AVAIL 
ID_FILESIZE 
ID_TOTAL 
ID_LEVELS 
ID_DISCARD 
ID_DISCARD_CLIPBOARD 
ID_COMPACT 
ChoiceID 
PlayID 
DetectID 
ID_INSERTA 
ID_INSERTB 
ID_REMOVE 
ID_IMPORT 
ID_EXPORT 
LoggerID_Save 
LoggerID_Clear 
LoggerID_Close 
kID_RadioButton_BouncingBall 
kID_RadioButton_Highlight 
ID_BITMAPBUTTON_MUSICAL_INSTRUMENT 
ID_SLIDER_PAN 
ID_SLIDER_GAIN 
ID_TOGGLEBUTTON_MUTE 
ID_TOGGLEBUTTON_SOLO 
kModuleDisabled 
kModuleEnabled 
kModuleAsk 
kModuleFailed 
kModuleNew 
STATE_Enabled 
STATE_Disabled 
STATE_New 
STATE_COUNT 
HostID 
PlayID 
RecordID 
ChannelsID 
ToolColumn 
ActionColumn 
ButtonsColumn 
CommentColumn 
UseCustomTrackNameID 
ID_WINDOW_SIZE 
ID_WINDOW_TYPE 
ID_PADDING_SIZE 
ID_SCALE 
ID_ALGORITHM 
ID_MINIMUM 
ID_MAXIMUM 
ID_GAIN 
ID_RANGE 
ID_FREQUENCY_GAIN 
ID_COLOR_SCHEME 
ID_SPECTRAL_SELECTION 
ID_DEFAULTS 
ID_DEFAULTS 
ID_SCALE 
ID_RANGE 
FSCKstatus_CLOSE_REQ 
FSCKstatus_CHANGED 
FSCKstatus_SAVE_AUP 
SNAP_OFF 
SNAP_NEAREST 
SNAP_PRIOR 
FirstID 
HSBarID 
VSBarID 
NextID 
FFT_SinCosBRTable 
FFT_SinCosTableVBR16 
FFT_SinCosTableBR16 
FFT_FastMathBR16 
FFT_FastMathBR24 
IdMainWindowSmall 
IdMainWindowLarge 
IdDirectory 
IdDirChoose 
IdOneSec 
IdTenSec 
IdOneMin 
IdFiveMin 
IdOneHour 
IdShortTracks 
IdMedTracks 
IdTallTracks 
IdDelayCheckBox 
IdCaptureFirst 
IdCaptureEffects 
IdCaptureScriptables 
IdCapturePreferences 
IdCaptureToolbars 
IdAllDelayedEvents 
IdCaptureWindowContents 
IdCaptureFullWindow 
IdCaptureWindowPlus 
IdCaptureFullScreen 
IdCaptureSelectionBar 
IdCaptureSpectralSelection 
IdCaptureTimer 
IdCaptureTools 
IdCaptureTransport 
IdCaptureMixer 
IdCaptureMeter 
IdCapturePlayMeter 
IdCaptureRecordMeter 
IdCaptureEdit 
IdCaptureDevice 
IdCaptureTranscription 
IdCaptureScrub 
IdCaptureTrackPanel 
IdCaptureRuler 
IdCaptureTracks 
IdCaptureFirstTrack 
IdCaptureSecondTrack 
IdCaptureLast 
IdLastDelayedEvent 
IdToggleBackgroundBlue 
IdToggleBackgroundWhite 
eOkButton 
eCancelButton 
eYesButton 
eNoButton 
eHelpButton 
ePreviewButton 
eDebugButton 
eSettingsButton 
ePreviewDryButton 
eApplyButton 
eCloseButton 
DontShowID 
ID_DATEPICKER_START 
ID_TIMETEXT_START 
ID_DATEPICKER_END 
ID_TIMETEXT_END 
ID_TIMETEXT_DURATION 
ID_AUTOSAVEPATH_BUTTON 
ID_AUTOSAVEPATH_TEXT 
ID_AUTOEXPORTPATH_BUTTON 
ID_AUTOEXPORTPATH_TEXT 
ID_AUTOSAVE_CHECKBOX 
ID_AUTOEXPORT_CHECKBOX 
POST_TIMER_RECORD_STOPPED 
POST_TIMER_RECORD_CANCEL_WAIT 
POST_TIMER_RECORD_CANCEL 
POST_TIMER_RECORD_NOTHING 
POST_TIMER_RECORD_CLOSE 
ETBCutID 
ETBCopyID 
ETBPasteID 
ETBTrimID 
ETBSilenceID 
ETBUndoID 
ETBRedoID 
ETBZoomInID 
ETBZoomOutID 
ETBZoomSelID 
ETBZoomFitID 
ETBNumButtons 
STBScrubID 
STBSeekID 
STBRulerID 
STBNumButtons 
STBFirstButton 
SelectionBarFirstID 
RateID 
SnapToID 
OnMenuID 
ChoiceID 
StartTimeID 
LengthTimeID 
CenterTimeID 
EndTimeID 
AudioTimeID 
TimeBarFirstID 
AudioPositionID 
ToolBarFloatMargin 
NoDockID 
TopDockID 
BotDockID 
DockCount 
TTB_PlaySpeed 
TTB_PlaySpeedSlider 
TTBNumButtons 
kTimerInterval 
kAffordancesAreaHeight 
kTopInset 
kTopMargin 
kBottomMargin 
kTrackSeparatorThickness 
kChannelSeparatorThickness 
OnSetFontID 
OnCutSelectedTextID 
OnCopySelectedTextID 
OnPasteSelectedTextID 
OnDeleteSelectedLabelID 
OnEditSelectedLabelID 
OnUpOctaveID 
OnDownOctaveID 
OnZoomFitVerticalID 
OnZoomResetID 
OnZoomDiv2ID 
OnZoomTimes2ID 
OnZoomHalfWaveID 
OnZoomInVerticalID 
OnZoomOutVerticalID 
OnZoomMaxID 
OnUpOctaveID 
OnDownOctaveID 
reserveDisplays 
OnRate8ID 
OnRate11ID 
OnRate16ID 
OnRate22ID 
OnRate44ID 
OnRate48ID 
OnRate88ID 
OnRate96ID 
OnRate176ID 
OnRate192ID 
OnRate352ID 
OnRate384ID 
OnRateOtherID 
On16BitID 
On24BitID 
OnFloatID 
OnMultiViewID 
OnSetDisplayId 
lastDisplayId 
OnChannelLeftID 
OnChannelRightID 
OnChannelMonoID 
OnMergeStereoID 
OnSwapChannelsID 
OnSplitStereoID 
OnSplitStereoMonoID 
ChannelMenuID 
FirstAttachedItemId 
OnZoomFitVerticalID 
OnZoomResetID 
OnZoomDiv2ID 
OnZoomTimes2ID 
OnZoomHalfWaveID 
OnZoomInVerticalID 
OnZoomOutVerticalID 
OnFirstWaveformScaleID 
OnLastWaveformScaleID 
OnFirstSpectrumScaleID 
OnLastSpectrumScaleID 
OnTimeTrackLinID 
OnTimeTrackLogID 
OnTimeTrackLogIntID 
OnSetTimeTrackRangeID 
SELECTION_RESIZE_REGION 
FREQ_SNAP_DISTANCE 
OnSetNameID 
OnMoveUpID 
OnMoveDownID 
OnMoveTopID 
OnMoveBottomID 
SCRUBBING_PIXEL_TOLERANCE 
kOneSecondCountdown 
SELECTION_RESIZE_REGION 
FREQ_SNAP_DISTANCE 
ID_TIMER 
DontShowID 
kToggleButtonID 
kTimerID 
OnMeterUpdateID 
OnMonitorID 
OnPreferencesID 
AV_FRAME_CROP_UNALIGNED 
AV_FRAME_CROP_UNALIGNED 
MAX_HFFT 
kVerticalPadding 

Width of padding below each channel group

kBorderThickness 
kShadowThickness 
kLeftInset 
kRightInset 
kLeftMargin 
kRightMargin 
kTrackInfoWidth 
ID_AUTOLOAD 
ID_AUTOWRAP 
ID_FONT 
ID_SPLITV 
ID_SPLITH 
ID_TOGGLECODE 
ID_TOGGLEOUTPUT 
ID_SMALLICONS 
ID_LARGEICONS 
ID_MATCH 
ID_TOP 
ID_UP 
ID_PREVIOUS 
ID_NEXT 
ID_GO 
ID_STOP 
ID_SCRIPT 
ID_OUTPUT 

Definition at line 293 of file ImportRaw.cpp.

293  {
294  ChoiceID = 9000,
295  PlayID,
296  DetectID,
297 };

Function Documentation

◆ getEndianChoice()

static int getEndianChoice ( int  sfFormat)
static

Definition at line 273 of file ImportRaw.cpp.

273  {
274  switch (sfFormat & SF_FORMAT_ENDMASK)
275  {
276  default:
277  case SF_ENDIAN_FILE:
278  return 0;
279  case SF_ENDIAN_LITTLE:
280  return 1;
281  case SF_ENDIAN_BIG:
282  return 2;
283  case SF_ENDIAN_CPU:
284  return 3;
285  }
286 }

Referenced by ImportRawDialog::ImportRawDialog(), and ImportRawDialog::OnDetect().

Here is the caller graph for this function:

◆ ImportRaw()

void ImportRaw ( const AudacityProject project,
wxWindow *  parent,
const wxString &  fileName,
WaveTrackFactory trackFactory,
TrackHolders outTracks 
)

Definition at line 110 of file ImportRaw.cpp.

112 {
113  outTracks.clear();
114 
115  TrackHolders results;
116  auto updateResult = ProgressResult::Success;
117 
118  {
119  // On first run, set default sample rate from project rate
120  if (ImportRawDialog::mRate < 100.)
122 
123  ImportRawDialog dlog(parent, fileName);
124  dlog.ShowModal();
125  if (!dlog.GetReturnCode())
126  return;
127 
128  int encoding = dlog.mEncoding;
129  unsigned numChannels = dlog.mChannels;
130  double rate = dlog.mRate;
131  sf_count_t offset = (sf_count_t)dlog.mOffset;
132  double percent = dlog.mPercent;
133 
134  SF_INFO sndInfo = { 0 };
135  sndInfo.samplerate = (int)rate;
136  sndInfo.channels = (int)numChannels;
137  sndInfo.format = encoding | SF_FORMAT_RAW;
138 
139  wxFile f; // will be closed when it goes out of scope
140  SFFile sndFile;
141 
142  if (f.Open(fileName)) {
143  // Even though there is an sf_open() that takes a filename, use the one that
144  // takes a file descriptor since wxWidgets can open a file with a Unicode name and
145  // libsndfile can't (under Windows).
146  sndFile.reset(SFCall<SNDFILE*>(sf_open_fd, f.fd(), SFM_READ, &sndInfo, FALSE));
147  }
148 
149  if (!sndFile){
150  char str[1000];
151  sf_error_str((SNDFILE *)NULL, str, 1000);
152  wxPrintf("%s\n", str);
153 
154  throw FileException{ FileException::Cause::Open, fileName };
155  }
156 
157 
158  {
159  int result = sf_command(sndFile.get(), SFC_SET_RAW_START_OFFSET, &offset, sizeof(offset));
160  if (result != 0) {
161  char str[1000];
162  sf_error_str(sndFile.get(), str, 1000);
163  wxPrintf("%s\n", str);
164 
165  throw FileException{ FileException::Cause::Read, fileName };
166  }
167  }
168  SFCall<sf_count_t>(sf_seek, sndFile.get(), 0, SEEK_SET);
169 
170  auto totalFrames =
171  // fraction of a sf_count_t value
172  (sampleCount)(sndInfo.frames * percent / 100.0);
173 
174  //
175  // Sample format:
176  //
177  // In general, go with the user's preferences. However, if
178  // the file is higher-quality, go with a format which preserves
179  // the quality of the original file.
180  //
181 
184 
185  results.resize(1);
186  auto &channels = results[0];
187  channels.resize(numChannels);
188 
189  {
190  // iter not used outside this scope.
191  auto iter = channels.begin();
192  for (decltype(numChannels) c = 0; c < numChannels; ++iter, ++c)
193  *iter = trackFactory->NewWaveTrack(format, rate);
194  }
195  const auto firstChannel = channels.begin()->get();
196  auto maxBlockSize = firstChannel->GetMaxBlockSize();
197 
198  SampleBuffer srcbuffer(maxBlockSize * numChannels, format);
199  SampleBuffer buffer(maxBlockSize, format);
200 
201  decltype(totalFrames) framescompleted = 0;
202  if (totalFrames < 0) {
203  wxASSERT(false);
204  totalFrames = 0;
205  }
206 
207  auto msg = XO("Importing %s").Format( wxFileName::FileName(fileName).GetFullName() );
208 
209  /* i18n-hint: 'Raw' means 'unprocessed' here and should usually be translated.*/
210  ProgressDialog progress(XO("Import Raw"), msg);
211 
212  size_t block;
213  do {
214  block =
215  limitSampleBufferSize( maxBlockSize, totalFrames - framescompleted );
216 
217  sf_count_t sf_result;
218  if (format == int16Sample)
219  sf_result = SFCall<sf_count_t>(sf_readf_short, sndFile.get(), (short *)srcbuffer.ptr(), block);
220  else
221  sf_result = SFCall<sf_count_t>(sf_readf_float, sndFile.get(), (float *)srcbuffer.ptr(), block);
222 
223  if (sf_result >= 0) {
224  block = sf_result;
225  }
226  else {
227  // This is not supposed to happen, sndfile.h says result is always
228  // a count, not an invalid value for error
229  throw FileException{ FileException::Cause::Read, fileName };
230  }
231 
232  if (block) {
233  auto iter = channels.begin();
234  for(decltype(numChannels) c = 0; c < numChannels; ++iter, ++c) {
235  if (format==int16Sample) {
236  for(decltype(block) j=0; j<block; j++)
237  ((short *)buffer.ptr())[j] =
238  ((short *)srcbuffer.ptr())[numChannels*j+c];
239  }
240  else {
241  for(decltype(block) j=0; j<block; j++)
242  ((float *)buffer.ptr())[j] =
243  ((float *)srcbuffer.ptr())[numChannels*j+c];
244  }
245 
246  iter->get()->Append(buffer.ptr(), (format == int16Sample)?int16Sample:floatSample, block);
247  }
248  framescompleted += block;
249  }
250 
251  updateResult = progress.Update(
252  framescompleted.as_long_long(),
253  totalFrames.as_long_long()
254  );
255  if (updateResult != ProgressResult::Success)
256  break;
257 
258  } while (block > 0 && framescompleted < totalFrames);
259  }
260 
261  if (updateResult == ProgressResult::Failed || updateResult == ProgressResult::Cancelled)
262  throw UserException{};
263 
264  if (!results.empty() && !results[0].empty()) {
265  for (const auto &channel : results[0])
266  channel->Flush();
267  outTracks.swap(results);
268  }
269 }

References ImportFileHandle::ChooseFormat(), floatSample, format, ProjectRate::Get(), ProjectRate::GetRate(), int16Sample, limitSampleBufferSize(), ImportRawDialog::mChannels, ImportRawDialog::mEncoding, ImportRawDialog::mOffset, ImportRawDialog::mPercent, ImportRawDialog::mRate, WaveTrackFactory::NewWaveTrack(), FileException::Open, SampleBuffer::ptr(), FileException::Read, sf_subtype_to_effective_format(), str, BasicUI::Success, ProgressDialog::Update(), and XO.

Referenced by anonymous_namespace{FileMenus.cpp}::DoImport().

Here is the call graph for this function:
Here is the caller graph for this function:
TrackHolders
std::vector< std::vector< std::shared_ptr< WaveTrack > > > TrackHolders
Definition: Import.h:39
BasicUI::ProgressResult::Success
@ Success
UserException
Can be thrown when user cancels operations, as with a progress dialog. Delayed handler does nothing.
Definition: UserException.h:17
str
#define str(a)
Definition: DBConnection.cpp:30
ProjectRate::Get
static ProjectRate & Get(AudacityProject &project)
Definition: ProjectRate.cpp:42
FileException::Cause::Read
@ Read
ChoiceID
@ ChoiceID
Definition: ImportRaw.cpp:294
FileException
Thrown for failure of file or database operations in deeply nested places.
Definition: FileException.h:19
RefreshCode::Cancelled
@ Cancelled
Definition: RefreshCode.h:23
XO
#define XO(s)
Definition: Internat.h:31
DetectID
@ DetectID
Definition: ImportRaw.cpp:296
floatSample
@ floatSample
Definition: SampleFormat.h:34
PlayID
@ PlayID
Definition: ImportRaw.cpp:295
ImportRawDialog
ImportRawDialog prompts you with options such as endianness and sample size to help you importing dat...
Definition: ImportRaw.cpp:62
ProgressDialog
ProgressDialog Class.
Definition: ProgressDialog.h:51
ImportFileHandle::ChooseFormat
static sampleFormat ChooseFormat(sampleFormat effectiveFormat)
Choose appropriate format, which will not be narrower than the specified one.
Definition: ImportPlugin.cpp:54
int16Sample
@ int16Sample
Definition: SampleFormat.h:32
sf_subtype_to_effective_format
sampleFormat sf_subtype_to_effective_format(unsigned int format)
Choose the narrowest value in the sampleFormat enumeration for a given libsndfile format.
Definition: FileFormats.cpp:229
FileException::Cause::Open
@ Open
format
int format
Definition: ExportPCM.cpp:56
SFFile
Definition: FileFormats.h:143
ProjectRate::GetRate
double GetRate() const
Definition: ProjectRate.cpp:68
SampleBuffer
Definition: SampleFormat.h:69
sampleCount
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:18
av_intfloat32::f
float f
Definition: ffmpeg-2.3.6-single-header.h:526
ImportRawDialog::mRate
static double mRate
Definition: ImportRaw.cpp:79
limitSampleBufferSize
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
Definition: SampleCount.cpp:23
WaveTrackFactory::NewWaveTrack
std::shared_ptr< WaveTrack > NewWaveTrack(sampleFormat format=(sampleFormat) 0, double rate=0)
Definition: WaveTrack.cpp:118