No me pita.
Mi pregunta puede parecer una gilipollez
Pero es que me estoy quedando loco con
Esto.
Estoy utilizando una libreria para hacer
Un programa con Delphi 6 funciona como
Si fuera MIDI pero por software, lo que
Pasa es que para hacer efectos se utiliza una funcion callback que nos da
la direccion donde cogemos el sonido y
donde lo dejamos pero por mucho que
intento dejar sonidos en el puntero de
destino ni pita ni ná.
Tengo una funcion callback de una libreria, es esta:
procedure miproc(pSource: TpSingle; pDestination:pSingle; nSamples: DWORD); stdcall;
Lo que hace esto es coger el buffer de una canal de sonido y lo que va a salir por el me lo pone en psource, yo luego hago lo que quiero con esos datos y se los tengo que devolver a pdestination, bueno eso es lo que creo que debo hacer y lo hago así:
var i:word;
a,b:single;
p:tpsingle;
begin
for i:=1 to nsamples do
begin
b:=psource^;
a:=2*b;
pdestination:=@a;
end;
end;
He comprobado que pdestination se llena
Con los datos de psource pero se supone
Que debería sonar algo y no lo hace, el error debería estar en como lleno pdestination pero creo que lo hago bien.
Te mando tambien todo lo que está relacionado con la función y lo miras.
Callback functions
type TpSingle = ^Single;
TFusrFX = procedure(pSource: TpSingle; pDestination: TpSingle;
nSamples: DWORD); stdcall;
The prototype of one or more optional callback procedures provided by the client application. Each channel can have its own TFusrFX procedure, assigned to it by VSL_OpenChannel.
If a TFusrFX procedure is specified for a channel, all audio output from that channel will be forwarded to this procedure instead of going straight to the final mixdown. This allows the client application to process the sound further, individually for each channel if needed.
Sound data is in stereo interleaved (left sample - right sample - left sample -right sample...) single precision (floating point) format. Amplitudes are normalized to the target 16 bit integer range (-32768 to 32767).
PSource: pointer
Points to the channel output buffer (i.e. The left sample in the first left-rigth pair in the buffer) with sound data ready to be mangled by the TFusrFX procedure.
PDestination: pointer
Points to the destination buffer (i.e. The left sample in the first left-rigth pair in the buffer) where the mangled sound data should be mixed down by the TFusrFX procedure.
NSamples: DWORD
The number of stereo samples (i.e. Left-rigth sample pairs) to read from pSource and to mix down to pDestination.
Mixing to pDestination should be performed by straight addition, sample by sample (no averaging or other kinds of weighting).
Te pongo tambien vsl_openchannel:
function VSL_OpenChannel(ChannelNumber: WORD;
UsrFX: TFusrFX;
OnProgramChange: TFonProgramChange): LRESULT; stdcall;
Opens the specified MIDI input channel (MIDI messages are sent to channels with VSL_PutMessage). Must be called before the channel can be used.
Returns...
VSL_OK if successful
VSL_OUT_OF_MEMORY if there isn't enough memory to create the new channel
VSL_ERROR if the call fails for some other reason.
Possible causes for a VSL_ERROR are calling VSL_OpenChannel before the virtual sampler has been initialized (see VSL_Init) and providing the number of a channel which has already been opened.
ChannelNumber: WORD
The number of the new MIDI channel. The full WORD range (0 to 65535) can be used, so you can have up to 65536 separate MIDI channels.
UsrFX: TFusrFX
The address of an optional callback function provided by the client application.
If a UsrFX function is specified, all audio output from the channel will be forwarded to this function instead of going straight to the final mixdown. This allows the client application to process the sound further, individually for each channel. See TFusrFX for details.
Specify a null pointer (nil) if you want channel output to go straight to the final mixdown.
OnProgramChange: TFonProgramChange
The address of an optional callback function provided by the client application.
If an OnProgramChange function is specified, it will be called every time a PRG is loaded or unloaded on this channel, reporting the new channel program status to the client application. The channel number is also reported, allowing OnProgramChange to be shared by several channels or to be "custom made" for each one. See
TFonProgramChange for details.
Specify a null pointer (nil) if you don't want to assign an OnProgramChange function to the channel.
All channels are opened as chromatic instrument channels, i.e. They interpret the program numbers in Program Change events (and in VSL_SetChannelProgramNumber calls) as chromatic instrument numbers. The initial GS bank (variation) number is zero. Use VSL_SetChannelBankNumber to select another sound bank or VSL_SetDrumChannel to turn a channel into a drum channel interpreting Program Change events as drum set numbers.
New channels start out "deaf": they will ignore all incoming MIDI messages until VSL_SetChannelReceiveOnis called. This allows the client application to take a few preparatory steps (e.g. Calling VSL_SetDrumChannel followed by VSL_SetChannelProgramNumber in order to load a default drum set) before any output is produced.
VSL_OpenChannel may be called while the virtual sampler is playing.
Esta función la he utilizado así y creo que funciona:
var
tre:tfusrfx;
begin
tre:=miproc;
if (VSL_OK = VSL_OpenChannelMIDIchannel,@tre, nil))
end;
Por si necesitas mas infomacion la libreria que estoy usando es
Virtual Sampler SDK, la dirección es:
www.polihedric.com/software
3
Pero es que me estoy quedando loco con
Esto.
Estoy utilizando una libreria para hacer
Un programa con Delphi 6 funciona como
Si fuera MIDI pero por software, lo que
Pasa es que para hacer efectos se utiliza una funcion callback que nos da
la direccion donde cogemos el sonido y
donde lo dejamos pero por mucho que
intento dejar sonidos en el puntero de
destino ni pita ni ná.
Tengo una funcion callback de una libreria, es esta:
procedure miproc(pSource: TpSingle; pDestination:pSingle; nSamples: DWORD); stdcall;
Lo que hace esto es coger el buffer de una canal de sonido y lo que va a salir por el me lo pone en psource, yo luego hago lo que quiero con esos datos y se los tengo que devolver a pdestination, bueno eso es lo que creo que debo hacer y lo hago así:
var i:word;
a,b:single;
p:tpsingle;
begin
for i:=1 to nsamples do
begin
b:=psource^;
a:=2*b;
pdestination:=@a;
end;
end;
He comprobado que pdestination se llena
Con los datos de psource pero se supone
Que debería sonar algo y no lo hace, el error debería estar en como lleno pdestination pero creo que lo hago bien.
Te mando tambien todo lo que está relacionado con la función y lo miras.
Callback functions
type TpSingle = ^Single;
TFusrFX = procedure(pSource: TpSingle; pDestination: TpSingle;
nSamples: DWORD); stdcall;
The prototype of one or more optional callback procedures provided by the client application. Each channel can have its own TFusrFX procedure, assigned to it by VSL_OpenChannel.
If a TFusrFX procedure is specified for a channel, all audio output from that channel will be forwarded to this procedure instead of going straight to the final mixdown. This allows the client application to process the sound further, individually for each channel if needed.
Sound data is in stereo interleaved (left sample - right sample - left sample -right sample...) single precision (floating point) format. Amplitudes are normalized to the target 16 bit integer range (-32768 to 32767).
PSource: pointer
Points to the channel output buffer (i.e. The left sample in the first left-rigth pair in the buffer) with sound data ready to be mangled by the TFusrFX procedure.
PDestination: pointer
Points to the destination buffer (i.e. The left sample in the first left-rigth pair in the buffer) where the mangled sound data should be mixed down by the TFusrFX procedure.
NSamples: DWORD
The number of stereo samples (i.e. Left-rigth sample pairs) to read from pSource and to mix down to pDestination.
Mixing to pDestination should be performed by straight addition, sample by sample (no averaging or other kinds of weighting).
Te pongo tambien vsl_openchannel:
function VSL_OpenChannel(ChannelNumber: WORD;
UsrFX: TFusrFX;
OnProgramChange: TFonProgramChange): LRESULT; stdcall;
Opens the specified MIDI input channel (MIDI messages are sent to channels with VSL_PutMessage). Must be called before the channel can be used.
Returns...
VSL_OK if successful
VSL_OUT_OF_MEMORY if there isn't enough memory to create the new channel
VSL_ERROR if the call fails for some other reason.
Possible causes for a VSL_ERROR are calling VSL_OpenChannel before the virtual sampler has been initialized (see VSL_Init) and providing the number of a channel which has already been opened.
ChannelNumber: WORD
The number of the new MIDI channel. The full WORD range (0 to 65535) can be used, so you can have up to 65536 separate MIDI channels.
UsrFX: TFusrFX
The address of an optional callback function provided by the client application.
If a UsrFX function is specified, all audio output from the channel will be forwarded to this function instead of going straight to the final mixdown. This allows the client application to process the sound further, individually for each channel. See TFusrFX for details.
Specify a null pointer (nil) if you want channel output to go straight to the final mixdown.
OnProgramChange: TFonProgramChange
The address of an optional callback function provided by the client application.
If an OnProgramChange function is specified, it will be called every time a PRG is loaded or unloaded on this channel, reporting the new channel program status to the client application. The channel number is also reported, allowing OnProgramChange to be shared by several channels or to be "custom made" for each one. See
TFonProgramChange for details.
Specify a null pointer (nil) if you don't want to assign an OnProgramChange function to the channel.
All channels are opened as chromatic instrument channels, i.e. They interpret the program numbers in Program Change events (and in VSL_SetChannelProgramNumber calls) as chromatic instrument numbers. The initial GS bank (variation) number is zero. Use VSL_SetChannelBankNumber to select another sound bank or VSL_SetDrumChannel to turn a channel into a drum channel interpreting Program Change events as drum set numbers.
New channels start out "deaf": they will ignore all incoming MIDI messages until VSL_SetChannelReceiveOnis called. This allows the client application to take a few preparatory steps (e.g. Calling VSL_SetDrumChannel followed by VSL_SetChannelProgramNumber in order to load a default drum set) before any output is produced.
VSL_OpenChannel may be called while the virtual sampler is playing.
Esta función la he utilizado así y creo que funciona:
var
tre:tfusrfx;
begin
tre:=miproc;
if (VSL_OK = VSL_OpenChannelMIDIchannel,@tre, nil))
end;
Por si necesitas mas infomacion la libreria que estoy usando es
Virtual Sampler SDK, la dirección es:
www.polihedric.com/software
3
1 respuesta
Respuesta de manuelmoro
1