WW      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUV 2016 2017 Mark Karpov BSD 3 clause(Mark Karpov <markkarpov@openmailbox.org> experimentalportableNone!"0OT]W8A helpers type synonym for the function to lift parsers.X6A helper type synonym for give up function signatures.YDA ds64  chunk used in RF64 WAVE extension. This type is not public.ZSize of RIFF chunk (64 bits)[Size of data chunk (64 bits)\!Total number of samples (64 bits)]ZA RIFF chunk allowing for different representations of its body. This type is not public.^Four-byte chunk tag_ Chunk size`Chunk body in some form!Exceptions the library can throw.Format of given file doesn't look like anything familiar. The first argument is a message explaining what's wrong and the second argument is the file name.)The library found a chunk which is not a datar chunk but is way too long. The first argument is the tag of the chunk and the second argument is the file name.QThe specified format is non-PCM, it's vanilla WAVE, but fact  chunk is missing.QSpeaker positions clarifying which exactly channels are packed in the WAVE file. Front left Front right Front center Sub-woofer  Back left  Back right Front left of center Front right of center  Back center Side left Side right Top centerTop front leftTop front centerTop front right Top back leftTop back centerTop back right9Sample formats with associated bit depth (when variable).{Unsigned/signed integers, the argument is the number of bits per sample (8 bit and less are encoded as unsigned integers).*Samples are 32 bit floating point numbers.*Samples are 64 bit floating point numbers. as flavor of WAVE file.'Classic WAVE file, 4 Gb size limitationWAVE file with RF64 extensionRepresentation of essential  information about a WAVE file. Every field in this record provides orthogonal piece of information, so no field can be calculated from other fields. The fields are complemented by the following functions that calculate some derivative parameters: (, ), *, +, and ,. #This specifies format of file this ) record was extracted/to be written to, . Default value is: .!%Sample rate in Hz, default is: 44100."YSample format. The library supports signed/unsigned integers and floats. Default value:  16.#The channel mask as a a of s. Default value is /.$^Offset in bytes from the beginning of file where actual sample data begins. Default value: 0.%.Size of audio data in bytes. Default value: 0.&>Total number of samples in the audio stream. Samples  here mean multi-channel samples, so one second of 44.1 kHz audio will have 44100 samples regardless of the number of channels. For PCM format it's deduced from size of data-block, for other formats it's read from/written to the fact  chunk. Default value: 0.'Other chunks as  (tag, body)! pairs. Only first four bytes of tagw are significant (and it must be four bytes long, if it's too short it will be padded by null bytes). Default value: [].(Byte rate of a given P file. Byte rate is the number of bytes it takes to encode one second of audio.) Bit rate in kilobits per second.*+Number of significant bits in every sample.+Block alignment of samples as number of bits per sample (rounded towards next multiplier of 8 if necessary) multiplied by number of channels. This is how many bytes it takes to encode a single multi-channel sample.,5Total number of channels present in the audio stream.-Duration in seconds..Front center (C)./ Front left (L), front right (R).0&L, R, back left (Lb), back right (Rb).13Surround: L, R, front center (C), back center (Cb).2%L, R, C, Lb, Rb, low frequency (LFE).3BL, R, C, Lb, Rb, front left-of-center, front right-of-center, LFE.4.L, R, C, side left (Ls), side right (Rs), LFE.5L, R, C, Lb, Rb, Ls, Rs, LFE.6Read B record from a WAVE file found at given path. This action throws - if the file is malformed and cannot be read.You can feed vanilla WAVE and RF64 files. The actual format is detected automatically from contents of the file, not by extension.IPCM with samples in form of integers and floats only are supported, see ^. Addition of other formats will be performed on request, please feel free to contact me at  %https://github.com/mrkkrp/wave/issues.tFinally, if fmt  chunk is not extensible, we try to guess channel mask from number of channels alone, here is how: 1 channel: front center (C)+2 channels: front left (L), front right (R)3 channels: L, R, C14 channels: L, R, back left (Lb), back right (Rb)5 channels: L, R, C, Lb, Rb 6 channels: L, R, C, LFE, Lb, RbK7 channels: L, R, C, LFE, back center (Cb), side left (Ls), side right (Rs)(8 channels: L, R, C, LFE, Lb, Rb, Ls, Rs)N channels: first N items are taken from [minBound..maxBound] of sbParse classic WAVE file.cParse RF64 file.dRead four bytes from given e0 and throw an exception if they are not WAVE .fRead WAVE chunks.goRead a ds64  chunk which contains RIFF chunk/data chunk lengths as 64 bit values and total number of samples.h#Parse WAVE format chunk from given i. Return error in j in case of failure.kRead the fact  chunk.lRead a classic RIFF ] (32 bit tag + 32 bit size).7Write a WAVE file. The   value specifies in which of the supported formats the file should be written. The action uses the provided callback to write WAVE audio data. $ and % from  are ignored, instead the values are inferred dynamically after using the callback. Further, the function takes care of the requirement that WAVE data should end on even byte boundary . The pad byte is written for you if necessary and included in data size.The & field will be inferred for PCM (including formats with samples represented as floats, i.e. always right now), so the provided value is not used.If  specifies floating point sample format, the fact  chunk is automatically generated and written (the chunk is required for all non-PCM formats by the spec), but only for vanilla WAVE.mWrite vanilla WAVE format.nWrite no data, at all.o/Write a chunk given its tag and body as strict is.p"Render a ds64  chunk as a stirct i.q Render format chunk as a strict i from a given .rRender fact chunk as a strict i.s Write a RIFF ]y. It's the responsibility of the programmer to ensure that specified size matches size of body that is actually written.t$Pulse-code modulation, vanilla WAVE.u+IEEE floats, 32 bit floating point samples.vExtensible format type.w6GUID for extensible format chunk corresponding to PCM.x=GUID for extensible format chunk corresponding to IEEE float.y$ to corresponding bit flag, as per  Ohttps://msdn.microsoft.com/en-us/library/windows/desktop/dd390971(v=vs.85).aspx.zGet speaker mask from a a of s.{&Transform a 4-byte mask into a set of s.|5Get default speaker set for given number of channels.} Does this 4 record requires extensible format chunk to be used?~Determine if given  is not PCM.<Round bits per sample to next multiplier of 8, if necessary.8Estimate total number of samples for a PCM audio stream.dWXYZ[\]^_`  !"#$%&'()*+,-./0123456Location of file to readbe to read fromHow to give upHow to lift parsers The resultce to read fromHow to give upHow to lift parsers The resultdfe to read fromHow to give upHow to lift parsers/Size of data chunk to use if 0xffffffff is read.Number of samples to use if 0xffffffff is readApply modifications to this  The resultghklOpened e to read the chunk from1Maximum size of chunk we want to grab into memoryError message or a ]7Where to save the fileParameters of the WAVE file-Callback that will be used to write WAVE datame to write toParameters of the WAVE fileCallback that writes WAVE datanoe where to write Chunk tag Chunk bodypqrsOpened e where to write the ]The ] to writetuvwxyz{|}~89:8  !"#$%&'()*+,-./012345678 !"#$%&' ()*+,-./012345679WXYZ[\]^_`   !"#$%&'()*+,-./0123456bcdfghkl7mnopqrstuvwxyz{|}~89:       !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnophqrstuvwxyz{|}~Z^!wave-0.1.4-7Nd27S018lZHgcdHPo4Fq8Codec.Audio.Wave WaveException BadFileFormatNonDataChunkIsTooLongNonPcmFormatButMissingFactSpeakerPositionSpeakerFrontLeftSpeakerFrontRightSpeakerFrontCenterSpeakerLowFrequencySpeakerBackLeftSpeakerBackRightSpeakerFrontLeftOfCenterSpeakerFrontRightOfCenterSpeakerBackCenterSpeakerSideLeftSpeakerSideRightSpeakerTopCenterSpeakerTopFrontLeftSpeakerTopFrontCenterSpeakerTopFrontRightSpeakerTopBackLeftSpeakerTopBackCenterSpeakerTopBackRight SampleFormatSampleFormatPcmIntSampleFormatIeeeFloat32BitSampleFormatIeeeFloat64Bit WaveFormat WaveVanillaWaveRF64WavewaveFileFormatwaveSampleRatewaveSampleFormatwaveChannelMaskwaveDataOffset waveDataSizewaveSamplesTotalwaveOtherChunks waveByteRate waveBitRatewaveBitsPerSamplewaveBlockAlign waveChannels waveDuration speakerMono speakerStereo speakerQuadspeakerSurround speaker5_1 speaker7_1speaker5_1Surroundspeaker7_1Surround readWaveFile writeWaveFile $fDefaultDs64$fExceptionWaveException $fDefaultWave$fShowWaveFormat$fReadWaveFormat$fEqWaveFormat$fOrdWaveFormat$fBoundedWaveFormat$fEnumWaveFormat$fDataWaveFormat$fShowSampleFormat$fReadSampleFormat$fEqSampleFormat$fOrdSampleFormat$fDataSampleFormat$fShowSpeakerPosition$fReadSpeakerPosition$fEqSpeakerPosition$fOrdSpeakerPosition$fBoundedSpeakerPosition$fEnumSpeakerPosition$fDataSpeakerPosition $fShowWave $fReadWave$fEqWave $fOrdWave $fDataWave$fShowWaveException$fReadWaveException$fEqWaveException$fDataWaveExceptionLiftGetGiveUpDs64 ds64RiffSize ds64DataSizeds64SamplesTotalChunkchunkTag chunkSize chunkBodycontainers-0.5.7.1 Data.Set.BaseSetreadWaveVanilla readWaveRF64 grabWaveTagbaseGHC.IO.Handle.TypesHandlegrabWaveChunksreadDs64 readWaveFmtbytestring-0.10.8.1Data.ByteString.Internal ByteString Data.EitherLeftreadFact readChunkwriteWaveVanilla writeNoData writeBsChunkrenderDs64ChunkrenderFmtChunkrenderFactChunk writeChunk waveFormatPcmwaveFormatIeeeFloatwaveFormatExtensibleksdataformatSubtypePcmksdataformatSubtypeIeeeFloat speakerToFlag toSpeakerMaskfromSpeakerMaskdefaultSpeakerSetisExtensibleFmtisNonPcmroundBitsPerSamplepcmSamplesTotal writeWaveRF64