sndfile

package
v0.0.0-...-e0c9ef8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2017 License: LGPL-2.1 Imports: 9 Imported by: 34

Documentation

Index

Constants

View Source
const (
	None        LoopMode = C.SF_LOOP_NONE
	Forward              = C.SF_LOOP_FORWARD
	Backward             = C.SF_LOOP_BACKWARD
	Alternating          = C.SF_LOOP_ALTERNATING
)
View Source
const (
	ChannelMapInvalid            = C.SF_CHANNEL_MAP_INVALID
	ChannelMapMono               = C.SF_CHANNEL_MAP_MONO
	ChannelMapLeft               = C.SF_CHANNEL_MAP_LEFT   /* Apple calls this 'Left' */
	ChannelMapRight              = C.SF_CHANNEL_MAP_RIGHT  /* Apple calls this 'Right' */
	ChannelMapCenter             = C.SF_CHANNEL_MAP_CENTER /* Apple calls this 'Center' */
	ChannelMapFrontLeft          = C.SF_CHANNEL_MAP_FRONT_LEFT
	ChannelMapFrontRight         = C.SF_CHANNEL_MAP_FRONT_RIGHT
	ChannelMapFrontCenter        = C.SF_CHANNEL_MAP_FRONT_CENTER
	ChannelMapRearCenter         = C.SF_CHANNEL_MAP_REAR_CENTER           /* Apple calls this 'Center Surround' Msft calls this 'Back Center' */
	ChannelMapRearLeft           = C.SF_CHANNEL_MAP_REAR_LEFT             /* Apple calls this 'Left Surround' Msft calls this 'Back Left' */
	ChannelMapRearRight          = C.SF_CHANNEL_MAP_REAR_RIGHT            /* Apple calls this 'Right Surround' Msft calls this 'Back Right' */
	ChannelMapLfe                = C.SF_CHANNEL_MAP_LFE                   /* Apple calls this 'LFEScreen' Msft calls this 'Low Frequency'  */
	ChannelMapFrontLeftOfCenter  = C.SF_CHANNEL_MAP_FRONT_LEFT_OF_CENTER  /* Apple calls this 'Left Center' */
	ChannelMapFrontRightOfCenter = C.SF_CHANNEL_MAP_FRONT_RIGHT_OF_CENTER /* Apple calls this 'Right Center */
	ChannelMapSideLeft           = C.SF_CHANNEL_MAP_SIDE_LEFT             /* Apple calls this 'Left Surround Direct' */
	ChannelMapSideRight          = C.SF_CHANNEL_MAP_SIDE_RIGHT            /* Apple calls this 'Right Surround Direct' */
	ChannelMapTopCenter          = C.SF_CHANNEL_MAP_TOP_CENTER            /* Apple calls this 'Top Center Surround' */
	ChannelMapTopFrontLeft       = C.SF_CHANNEL_MAP_TOP_FRONT_LEFT        /* Apple calls this 'Vertical Height Left' */
	ChannelMapTopFrontRight      = C.SF_CHANNEL_MAP_TOP_FRONT_RIGHT       /* Apple calls this 'Vertical Height Right' */
	ChannelMapTopFrontCenter     = C.SF_CHANNEL_MAP_TOP_FRONT_CENTER      /* Apple calls this 'Vertical Height Center' */
	ChannelMapTopRearLeft        = C.SF_CHANNEL_MAP_TOP_REAR_LEFT         /* Apple and MS call this 'Top Back Left' */
	ChannelMapTopRearRight       = C.SF_CHANNEL_MAP_TOP_REAR_RIGHT        /* Apple and MS call this 'Top Back Right' */
	ChannelMapTopRearCenter      = C.SF_CHANNEL_MAP_TOP_REAR_CENTER       /* Apple and MS call this 'Top Back Center' */
	ChannelMapAmbisonicBW        = C.SF_CHANNEL_MAP_AMBISONIC_B_W
	ChannelMapAmbisonicBX        = C.SF_CHANNEL_MAP_AMBISONIC_B_X
	ChannelMapAmbisonicBY        = C.SF_CHANNEL_MAP_AMBISONIC_B_Y
	ChannelMapAmbisonicBZ        = C.SF_CHANNEL_MAP_AMBISONIC_B_Z
	ChannelMapMax                = C.SF_CHANNEL_MAP_MAX
)
View Source
const AmbisonicBFormat int = int(C.SF_AMBISONIC_B_FORMAT)
View Source
const AmbisonicNone int = int(C.SF_AMBISONIC_NONE)

Variables

This section is empty.

Functions

func FormatCheck

func FormatCheck(i Info) bool

This function allows the caller to check if a set of parameters in the Info struct is valid before calling Open in Write mode. FormatCheck returns true if the parameters are valid and false otherwise.

func GenericCmd

func GenericCmd(f *File, cmd C.int, data unsafe.Pointer, datasize int) int

This allows libsndfile experts to use the command interface for commands not currently supported. See http://www.mega-nerd.com/libsndfile/command.html The f argument may be nil in cases where the command does not require a SNDFILE argument. The method's cmd, data, and datasize arguments are used the same way as the correspondingly named arguments for sf_command

func GetFormatInfo

func GetFormatInfo(format int) (oformat int, name string, extension string, ok bool)

When GetFormatInfo() is called, the format argument is examined and if (format & SF_FORMAT_TYPEMASK) is a valid format then the returned strings contain information about the given major type. If (format & SF_FORMAT_TYPEMASK) is FALSE and (format & SF_FORMAT_SUBMASK) is a valid subtype format then the returned strings contain information about the given subtype.

func GetLibVersion

func GetLibVersion() (s string, err error)

GetLibVersion retrieves the version of the library as a string

func GetMajorFormatCount

func GetMajorFormatCount() int

Retrieve the number of major formats supported by libsndfile.

func GetMajorFormatInfo

func GetMajorFormatInfo(format int) (oformat int, name string, extension string, ok bool)

Retrieve information about a major format type For a more comprehensive example, see the program list_formats.c in the examples/ directory of the libsndfile source code distribution.

func GetSimpleFormat

func GetSimpleFormat(format int) (oformat int, name string, extension string, ok bool)

Retrieve information about a simple format. The value of the format argument should be the format number (ie 0 <= format <= count value obtained using GetSimpleFormatCount()). The returned format argument is suitable for use in sndfile.Open()

func GetSimpleFormatCount

func GetSimpleFormatCount() int

Retrieve the number of simple formats supported by libsndfile.

func GetSubFormatCount

func GetSubFormatCount() int

Retrieve the number of subformats supported by libsndfile.

func GetSubFormatInfo

func GetSubFormatInfo(format int) (oformat int, name string, ok bool)

Enumerate the subtypes (this function does not translate a subtype into a string describing that subtype). A typical use case might be retrieving a string description of all subtypes so that a dialog box can be filled in.

Types

type BroadcastInfo

type BroadcastInfo struct {
	Description          string
	Originator           string
	Originator_reference string
	Origination_date     string
	Origination_time     string
	Time_reference_low   uint32
	Time_reference_high  uint32
	Version              uint16
	Umid                 string
	Coding_history       string
}

type File

type File struct {
	Format Info
	// contains filtered or unexported fields
}

A sound file. Does not conform to io.Reader.

func Open

func Open(name string, mode Mode, info *Info) (o *File, err error)

returns a pointer to the file and a nil error if successful. In case of error, err will be non-nil.

func OpenFd

func OpenFd(fd uintptr, mode Mode, info *Info, close_desc bool) (o *File, err error)

This probably won't work on windows, because go uses handles instead of integer file descriptors on Windows. Unfortunately I have no way to test. The mode and info arguments, and the return values, are the same as for Open(). close_desc should be true if you want the library to close the file descriptor when you close the sndfile.File object

func OpenVirtual

func OpenVirtual(v VirtualIo, mode Mode, info *Info) (f *File, err error)

Opens a soundfile from a virtual file I/O context which is provided by the caller. This is usually used to interface libsndfile to a stream or buffer based system. Apart from the c and user_data parameters this function behaves like sf_open. THIS PART OF THE PACKAGE IS EXPERIMENTAL. Don't use it yet.

func (*File) CalcMaxAllChannels

func (f *File) CalcMaxAllChannels() (ret []float64, err error)

Calculate the peak value (ie a single number) for each channel. This involves reading through the whole file which can be slow on large files.

func (*File) CalcNormMaxAllChannels

func (f *File) CalcNormMaxAllChannels() (ret []float64, err error)

Calculate the normalised peak for each channel. This involves reading through the whole file which can be slow on large files.

func (*File) CalcNormSignalMax

func (f *File) CalcNormSignalMax() (ret float64, err error)

Retrieve the measured normalised maximum signal value. This involves reading through the whole file which can be slow on large files.

func (*File) CalcSignalMax

func (f *File) CalcSignalMax() (ret float64, err error)

Retrieve the measured maximum signal value. This involves reading through the whole file which can be slow on large files.

func (*File) Close

func (f *File) Close() (err error)

The close function closes the file, deallocates its internal buffers and returns a non-nil error value in case of error

func (*File) GetBroadcastInfo

func (f *File) GetBroadcastInfo() (bi *BroadcastInfo, ok bool)

Retrieve the Broadcast Extension Chunk from WAV (and related) files.

func (*File) GetChannelMapInfo

func (f *File) GetChannelMapInfo() (channels []int32, err error)

Returns a slice full of integers detailing the position of each channel in the file. err will be non-nil on an actual error

func (*File) GetClipping

func (f *File) GetClipping(clip bool) bool

Is automatic clipping when doing floating point to integer conversion on?

func (*File) GetDoubleNormalization

func (f *File) GetDoubleNormalization() bool

Returns the current float64 normalization mode.

func (*File) GetEmbeddedFileInfo

func (f *File) GetEmbeddedFileInfo() (offset, length int64, err error)

Get the file offset and file length of a file enbedded within another larger file. The value of the offset return value will be the offsets in bytes from the start of the outer file to the start of the embedded audio file. The value of the length return value will be the length in bytes of the embedded file. Untested.

func (*File) GetFloatNormalization

func (f *File) GetFloatNormalization() bool

Returns the current float32 normalization mode.

func (*File) GetInstrument

func (f *File) GetInstrument() (i *Instrument)

Return pointer to populated structure if the file header contains instrument information for the file. nil otherwise.

func (*File) GetLogInfo

func (f *File) GetLogInfo() (s string, err error)

Retrieve the log buffer generated when opening a file as a string. This log buffer can often contain a good reason for why libsndfile failed to open a particular file.

func (*File) GetLoopInfo

func (f *File) GetLoopInfo() (i *LoopInfo)

Returns populated structure if file contains loop info, otherwise nil. Untested.

func (*File) GetMaxAllChannels

func (f *File) GetMaxAllChannels() (ret []float64, ok bool)

Retrieve the peak value for the file as stored in the file header.

func (*File) GetSignalMax

func (f *File) GetSignalMax() (ret float64, ok bool)

Retrieve the peak value for the file as stored in the file header.

func (*File) GetString

func (f *File) GetString(typ StringType) (out string)

The GetString() method returns the specified string if it exists and a NULL pointer otherwise. In addition to the string ids above, First (== Title) and Last (always the same as the highest numbers string id) are also available to allow iteration over all the available string ids.

func (*File) RawNeedsEndianSwap

func (f *File) RawNeedsEndianSwap() bool

For instance, will return true on when reading WAV containing SF_FORMAT_PCM_16 data on a big endian machine and false on a little endian machine.

func (*File) ReadFrames

func (f *File) ReadFrames(out interface{}) (read int64, err error)

The file read frames functions fill the array pointed to by out with the requested number of frames of data. The array must be large enough to hold the product of frames and the number of channels.

The sf_readf_XXXX functions return the number of frames read. Unless the end of the file was reached during the read, the return value should equal the number of frames requested. Attempts to read beyond the end of the file will not result in an error but will cause the sf_readf_XXXX functions to return less than the number of frames requested or 0 if already at the end of the file.

func (*File) ReadItems

func (f *File) ReadItems(out interface{}) (read int64, err error)

The file read items functions fill the array pointed to by out with the requested number of items. The length of out must be a product of the number of channels or an error will occur.

It is important to note that the data type used by the calling program and the data format of the file do not need to be the same. For instance, it is possible to open a 16 bit PCM encoded WAV file and read the data into a slice of floats. The library seamlessly converts between the two formats on-the-fly. See Note 1.

Returns the number of items read. Unless the end of the file was reached during the read, the return value should equal the number of items requested. Attempts to read beyond the end of the file will not result in an error but will cause ReadItems to return less than the number of items requested or 0 if already at the end of the file.

out must be a slice or array of int, int16, int32, float32, or float64.

func (*File) ReadRaw

func (f *File) ReadRaw(data []byte) (read int64, err error)

The raw read and write functions return the number of bytes read or written (which should be the same as the bytes parameter) and any error that occurs while reading or writing needs test

func (*File) Seek

func (f *File) Seek(frames int64, w Whence) (offset int64, err error)

The file seek functions work much like lseek in unistd.h with the exception that the non-audio data is ignored and the seek only moves within the audio data section of the file. In addition, seeks are defined in number of (multichannel) frames. Therefore, a seek in a stereo file from the current position forward with an offset of 1 would skip forward by one sample of both channels. This function returns the new offset, and a non-nil error value if unsuccessful

func (*File) SetAddPeakChunk

func (f *File) SetAddPeakChunk(set bool) bool

Note : This call must be made before any data is written to the file.

func (*File) SetBroadcastInfo

func (f *File) SetBroadcastInfo(bi *BroadcastInfo) (err error)

Set the Broadcast Extension Chunk from WAV (and related) files.

func (*File) SetChannelMapInfo

func (f *File) SetChannelMapInfo(channels []int32) (err error)

func (*File) SetClipping

func (f *File) SetClipping(clip bool) bool

Turn on/off automatic clipping when doing floating point to integer conversion.

func (*File) SetDoubleNormalization

func (f *File) SetDoubleNormalization(norm bool) bool

This command only affects data read from or written to using ReadItems, ReadFrames, WriteItems, or WriteFrames with slices of float64.

For read operations setting normalisation to true means that the data from all subsequent reads will be be normalised to the range [-1.0, 1.0].

For write operations, setting normalisation to true means than all data supplied to the float write functions should be in the range [-1.0, 1.0] and will be scaled for the file format as necessary.

For both cases, setting normalisation to false means that no scaling will take place.

Returns the previous normalization setting.

func (*File) SetFloatIntScaleRead

func (f *File) SetFloatIntScaleRead(scale bool) bool

Set/clear the scale factor when integer (short/int) data is read from a file containing floating point data.

func (*File) SetFloatNormalization

func (f *File) SetFloatNormalization(norm bool) bool

This command only affects data read from or written to using ReadItems, ReadFrames, WriteItems, or WriteFrames with slices of float32.

For read operations setting normalisation to true means that the data from all subsequent reads will be be normalised to the range [-1.0, 1.0].

For write operations, setting normalisation to true means than all data supplied to the float write functions should be in the range [-1.0, 1.0] and will be scaled for the file format as necessary.

For both cases, setting normalisation to false means that no scaling will take place.

Returns the previous normalization setting.

func (*File) SetInstrument

func (f *File) SetInstrument(i *Instrument) bool

Return true if the file header contains instrument information for the file. false otherwise.

func (*File) SetIntFloatScaleWrite

func (f *File) SetIntFloatScaleWrite(scale bool) bool

Set/clear the scale factor when integer (short/int) data is written to a file as floating point data.

func (*File) SetRawStartOffset

func (f *File) SetRawStartOffset(count int64) (err error)

Change the data start offset for files opened up as SF_FORMAT_RAW. libsndfile implements this but it appears to not do anything useful that you can't accomplish with seek, so consider this deprecated.

func (*File) SetString

func (f *File) SetString(in string, typ StringType) (err error)

The SetString() method sets the string data in a file. It returns nil on success and non-nil on error.

func (*File) SetUpdateHeaderAuto

func (f *File) SetUpdateHeaderAuto(set bool) bool

Similar to SFC_UPDATE_HEADER_NOW but updates the header at the end of every call to the sf_write* functions.

func (*File) SetVbrQuality

func (f *File) SetVbrQuality(q float64) (err error)

Set the the Variable Bit Rate encoding quality. The encoding quality value should be between 0.0 (lowest quality) and 1.0 (highest quality). Untested.

func (*File) Truncate

func (f *File) Truncate(count int64) (err error)

Truncates a file to /count/ frames. After this command, both the read and the write pointer will be at the new end of the file. This command will fail (returning non-zero) if the requested truncate position is beyond the end of the file.

func (*File) UpdateHeaderNow

func (f *File) UpdateHeaderNow()

There are however situations where large files are being generated and it would be nice to have valid data in the header before the file is complete. Using this command will update the file header to reflect the amount of data written to the file so far. Other programs opening the file for read (before any more data is written) will then read a valid sound file header.

func (*File) WavexGetAmbisonic

func (f *File) WavexGetAmbisonic() int

Test if the current file has the GUID of a WAVEX file for any of the Ambisonic formats. returns AmbisonicNone or AmbisonicBFormat, or zero if the file format does not support Ambisonic formats

func (*File) WavexSetAmbisonic

func (f *File) WavexSetAmbisonic(ambi int) int

Set the GUID of a new WAVEX file to indicate an Ambisonics format. returns format that was just set, or zero if the file format does not support Ambisonic formats

func (*File) WriteFrames

func (f *File) WriteFrames(in interface{}) (written int64, err error)

The file write frames function writes the data in the array or slice pointed to by the input argument to the file. The items parameter must be an integer product of the number of channels or an error will occur.

It is important to note that the data type used by the calling program and the data format of the file do not need to be the same. For instance, it is possible to open a 16 bit PCM encoded WAV file and write the data from a []float32. The library seamlessly converts between the two formats on-the-fly.

Returns the number of frames written (which should be the same as the length of the input parameter divided by the number of channels). err wil be nil except in case of failure

func (*File) WriteItems

func (f *File) WriteItems(in interface{}) (written int64, err error)

func (*File) WriteRaw

func (f *File) WriteRaw(data []byte) (written int64, err error)

The raw read and write functions return the number of bytes read or written (which should be the same as the bytes parameter) and any error that occurs while reading or writing needs test

func (*File) WriteSync

func (f *File) WriteSync()

If the file is opened Write or ReadWrite, call the operating system's function to force the writing of all file cache buffers to disk. If the file is opened Read no action is taken.

type Format

type Format int32

The format field in the above Info structure is made up of the bit-wise OR of a major format type (values between 0x10000 and 0x08000000), a minor format type (with values less than 0x10000) and an optional endian-ness value. The currently understood formats are taken from sndfile.h as follows and also include bitmasks for separating major and minor file types. Not all combinations of endian-ness and major and minor file types are valid.

const (
	SF_FORMAT_WAV   Format = 0x010000 /* Microsoft WAV format (little endian). */
	SF_FORMAT_AIFF  Format = 0x020000 /* Apple/SGI AIFF format (big endian). */
	SF_FORMAT_AU    Format = 0x030000 /* Sun/NeXT AU format (big endian). */
	SF_FORMAT_RAW   Format = 0x040000 /* RAW PCM data. */
	SF_FORMAT_PAF   Format = 0x050000 /* Ensoniq PARIS file format. */
	SF_FORMAT_SVX   Format = 0x060000 /* Amiga IFF / SVX8 / SV16 format. */
	SF_FORMAT_NIST  Format = 0x070000 /* Sphere NIST format. */
	SF_FORMAT_VOC   Format = 0x080000 /* VOC files. */
	SF_FORMAT_IRCAM Format = 0x0A0000 /* Berkeley/IRCAM/CARL */
	SF_FORMAT_W64   Format = 0x0B0000 /* Sonic Foundry's 64 bit RIFF/WAV */
	SF_FORMAT_MAT4  Format = 0x0C0000 /* Matlab (tm) V4.2 / GNU Octave 2.0 */
	SF_FORMAT_MAT5  Format = 0x0D0000 /* Matlab (tm) V5.0 / GNU Octave 2.1 */
	SF_FORMAT_PVF   Format = 0x0E0000 /* Portable Voice Format */
	SF_FORMAT_XI    Format = 0x0F0000 /* Fasttracker 2 Extended Instrument */
	SF_FORMAT_HTK   Format = 0x100000 /* HMM Tool Kit format */
	SF_FORMAT_SDS   Format = 0x110000 /* Midi Sample Dump Standard */
	SF_FORMAT_AVR   Format = 0x120000 /* Audio Visual Research */
	SF_FORMAT_WAVEX Format = 0x130000 /* MS WAVE with WAVEFORMATEX */
	SF_FORMAT_SD2   Format = 0x160000 /* Sound Designer 2 */
	SF_FORMAT_FLAC  Format = 0x170000 /* FLAC lossless file format */
	SF_FORMAT_CAF   Format = 0x180000 /* Core Audio File format */
	SF_FORMAT_WVE   Format = 0x190000 /* Psion WVE format */
	SF_FORMAT_OGG   Format = 0x200000 /* Xiph OGG container */
	SF_FORMAT_MPC2K Format = 0x210000 /* Akai MPC 2000 sampler */
	SF_FORMAT_RF64  Format = 0x220000 /* RF64 WAV file */

	SF_FORMAT_PCM_S8 Format = 0x0001 /* Signed 8 bit data */
	SF_FORMAT_PCM_16 Format = 0x0002 /* Signed 16 bit data */
	SF_FORMAT_PCM_24 Format = 0x0003 /* Signed 24 bit data */
	SF_FORMAT_PCM_32 Format = 0x0004 /* Signed 32 bit data */

	SF_FORMAT_PCM_U8 Format = 0x0005 /* Unsigned 8 bit data (WAV and RAW only) */

	SF_FORMAT_FLOAT  Format = 0x0006 /* 32 bit float data */
	SF_FORMAT_DOUBLE Format = 0x0007 /* 64 bit float data */

	SF_FORMAT_ULAW      Format = 0x0010 /* U-Law encoded. */
	SF_FORMAT_ALAW      Format = 0x0011 /* A-Law encoded. */
	SF_FORMAT_IMA_ADPCM Format = 0x0012 /* IMA ADPCM. */
	SF_FORMAT_MS_ADPCM  Format = 0x0013 /* Microsoft ADPCM. */

	SF_FORMAT_GSM610    Format = 0x0020 /* GSM 6.10 encoding. */
	SF_FORMAT_VOX_ADPCM Format = 0x0021 /* Oki Dialogic ADPCM encoding. */

	SF_FORMAT_G721_32 Format = 0x0030 /* 32kbs G721 ADPCM encoding. */
	SF_FORMAT_G723_24 Format = 0x0031 /* 24kbs G723 ADPCM encoding. */
	SF_FORMAT_G723_40 Format = 0x0032 /* 40kbs G723 ADPCM encoding. */

	SF_FORMAT_DWVW_12 Format = 0x0040 /* 12 bit Delta Width Variable Word encoding. */
	SF_FORMAT_DWVW_16 Format = 0x0041 /* 16 bit Delta Width Variable Word encoding. */
	SF_FORMAT_DWVW_24 Format = 0x0042 /* 24 bit Delta Width Variable Word encoding. */
	SF_FORMAT_DWVW_N  Format = 0x0043 /* N bit Delta Width Variable Word encoding. */

	SF_FORMAT_DPCM_8  Format = 0x0050 /* 8 bit differential PCM (XI only) */
	SF_FORMAT_DPCM_16 Format = 0x0051 /* 16 bit differential PCM (XI only) */

	SF_FORMAT_VORBIS Format = 0x0060 /* Xiph Vorbis encoding. */

	SF_ENDIAN_FILE   Format = 0x00000000 /* Default file endian-ness. */
	SF_ENDIAN_LITTLE Format = 0x10000000 /* Force little endian-ness. */
	SF_ENDIAN_BIG    Format = 0x20000000 /* Force big endian-ness. */
	SF_ENDIAN_CPU    Format = 0x30000000 /* Force CPU endian-ness. */

	SF_FORMAT_SUBMASK  Format = 0x0000FFFF
	SF_FORMAT_TYPEMASK Format = 0x0FFF0000
	SF_FORMAT_ENDMASK  Format = 0x30000000
)

type Info

type Info struct {
	Frames     int64
	Samplerate int32
	Channels   int32
	Format     Format
	Sections   int32
	Seekable   int32
}

Info is the struct needed to open a file for reading or writing. When opening a file for reading, everything may generally be left zeroed. The only exception to this is the case of RAW files where the caller has to set the samplerate, channels and format fields to valid values.

type Instrument

type Instrument struct {
	Gain             int
	Basenote, Detune int8
	Velocity         [2]int8 // low byte is index 0
	Key              [2]int8 // low byte is index 0
	LoopCount        int
	Loops            [16]struct {
		Mode              LoopMode
		Start, End, Count uint
	}
}

type LoopInfo

type LoopInfo struct {
	TimeSig struct {
		Numerator   int16 // any positive integer
		Denominator int16 // any positive power of 2
	}
	Mode    LoopMode
	Beats   int     // not amount of quarter notes. a full bar of 7/8 is 7 bears
	Bpm     float32 // Suggestion
	RootKey int     // MIDI Note
	Future  [6]int  // nuffink
}

type LoopMode

type LoopMode int

type Mode

type Mode int

File mode: Read, Write, or ReadWrite

const (
	Read      Mode = C.SFM_READ
	Write     Mode = C.SFM_WRITE
	ReadWrite Mode = C.SFM_RDWR
)

type VIO_get_filelen

type VIO_get_filelen func(interface{}) int64

type VIO_read

type VIO_read func([]byte, interface{}) int64

type VIO_seek

type VIO_seek func(int64, Whence, interface{}) int64

type VIO_tell

type VIO_tell func(interface{}) int64

type VIO_write

type VIO_write func([]byte, interface{}) int64

type VirtualIo

type VirtualIo struct {
	GetLength VIO_get_filelen
	Seek      VIO_seek
	Read      VIO_read
	Write     VIO_write
	Tell      VIO_tell
	UserData  interface{}
}

You must provide the following: UserData is the virtual file context. It is opaque to this layer. GetLength returns the length of the virtual file in BYTES Seek - The virtual file context must seek to offset using the seek mode provided by whence which is one of Read - The virtual file context must copy ("read") "count" bytes into the buffer provided by ptr and return the count of actually copied bytes. (only when file is opened in Read or ReadWrite mode) Write - The virtual file context must process "count" bytes stored in the buffer passed with ptr and return the count of actually processed bytes. Tell - Return the current position of the virtual file context.

type Whence

type Whence C.int

Whence args for Seek()

const (
	Set     Whence = C.SEEK_SET // The offset is set to the start of the audio data plus offset (multichannel) frames.
	Current Whence = C.SEEK_CUR //The offset is set to its current location plus offset (multichannel) frames.
	End     Whence = C.SEEK_END //The offset is set to the end of the data plus offset (multichannel) frames.
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL