Edytuj

Udostępnij za pośrednictwem


AudioBuffers.SetData Method

Definition

Overloads

SetData(Int32, IntPtr)

Sets the data buffer for one of the audio buffers, without updating the buffer size.

SetData(Int32, IntPtr, Int32)

Sets the data buffer for one of the audio buffers.

SetData(Int32, IntPtr)

Sets the data buffer for one of the audio buffers, without updating the buffer size.

public void SetData (int index, IntPtr data);
member this.SetData : int * nativeint -> unit

Parameters

index
Int32

Index of the buffer to access.

data
IntPtr

nativeint

Pointer to the data to set for the specified buffer.

Remarks

You can use this method to swap out one of the buffers, without updating the size of the buffer.

//
// Creating an AudioBuffers structure 
//
AudioBuffers SetupBuffers (int n = 2, int size = 4096)
{
    var buffers = new AudioBuffers (n);
    for (int i = 0; i < n; i++)
	buffers.SetData (i, MyBuffers [0][i], size);
    return buffers;
}

//
// Swap the buffers
//
void SwapBuffers (AudioBuffers buffers, int bufferGroup)
{
    for (int i = 0; i < buffers.Count; i++)
    	buffers.SetData (i, MyBuffers [bufferGroup][i]);
}

Applies to

SetData(Int32, IntPtr, Int32)

Sets the data buffer for one of the audio buffers.

public void SetData (int index, IntPtr data, int dataByteSize);
member this.SetData : int * nativeint * int -> unit

Parameters

index
Int32

Index of the buffer to access.

data
IntPtr

nativeint

Pointer to the data to set for the specified buffer.

dataByteSize
Int32

Size of the buffer.

Remarks

//
// Creating an AudioBuffers structure 
//
AudioBuffers SetupBuffers (int n = 2, int size = 4096)
{
    var buffers = new AudioBuffers (n);
    for (int i = 0; i < n; i++){
        var buffer = Marshal.AllocHGlobal (size);
	buffers.SetData (i, buffer, size);
    }
    return buffers;
}

void ReleaseBuffers (AudioBuffers buffers)
{
    for (int i = 0; i < buffers.Count; i++){
        var buf = buffers [i];
        Marshal.ReleaseHGlobal (buf.Data);                
    }
    buffers.Dispose ();
}

Applies to