
Pour le moment il n'y en a pas (il fait tellement peu chaud

Quelles sont vos méthodes ?
Scaramanga a écrit:Désolé on a un peu débordé de ton sujet...![]()
Scaramanga a écrit:Je pense que ça peut fonctionner. On doit pouvoir optimiser en remplacent le HP d'origine par un Tweeter ( Haut parleur spécialisé dans les aigües), mais faut jouer du fEr à souder !
CapJack a écrit:Scara, tu utilises quoi comme code source ?
unit PlaySoundU;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, MMSystem;
type
TVolumeLevel = 0..32767;
procedure MakeSound(Frequency{Hz}, Duration{mSec}: Integer; Volume: TVolumeLevel);
implementation
procedure MakeSound(Frequency{Hz}, Duration{mSec}: Integer; Volume: TVolumeLevel);
{writes tone to memory and plays it}
var
WaveFormatEx: TWaveFormatEx;
MS: TMemoryStream;
i, TempInt, DataCount, RiffCount: integer;
SoundValue: Cardinal;
w: double; // omega ( 2 * pi * frequency)
const
Mono: Word = $0001;
SampleRate: Integer = 96000; // 8000, 11025, 22050, or 44100
RiffId: string = 'RIFF';
WaveId: string = 'WAVE';
FmtId: string = 'fmt ';
DataId: string = 'data';
begin
if Frequency > (0.6 * SampleRate) then
begin
ShowMessage(Format('Sample rate of %d is too Low to play a tone of %dHz',
[SampleRate, Frequency]));
Exit;
end;
with WaveFormatEx do
begin
wFormatTag := WAVE_FORMAT_PCM;
nChannels := Mono;
nSamplesPerSec := SampleRate;
wBitsPerSample := $0010;
nBlockAlign := (nChannels * wBitsPerSample) div 8;
nAvgBytesPerSec := nSamplesPerSec * nBlockAlign;
cbSize := 0;
end;
MS := TMemoryStream.Create;
with MS do
begin
{Calculate length of sound data and of file data}
DataCount := (Duration * SampleRate) div 1000; // sound data
RiffCount := Length(WaveId) + Length(FmtId) + SizeOf(DWORD) +
SizeOf(TWaveFormatEx) + Length(DataId) + SizeOf(DWORD) + DataCount; // file data
{write out the wave header}
Write(RiffId[1], 4); // 'RIFF'
Write(RiffCount, SizeOf(DWORD)); // file data size
Write(WaveId[1], Length(WaveId)); // 'WAVE'
Write(FmtId[1], Length(FmtId)); // 'fmt '
TempInt := SizeOf(TWaveFormatEx);
Write(TempInt, SizeOf(DWORD)); // TWaveFormat data size
Write(WaveFormatEx, SizeOf(TWaveFormatEx)); // WaveFormatEx record
Write(DataId[1], Length(DataId)); // 'data'
Write(DataCount, SizeOf(DWORD)); // sound data size
{calculate and write out the tone signal} // now the data values
w := 2 * Pi * Frequency; // omega
for i := 0 to DataCount - 1 do
begin
SoundValue := round(Volume * sin(i * w / SampleRate)); // wt = w * i / SampleRate
Write(SoundValue, WaveFormatEx.wBitsPerSample shr 3);
end;
{now play the sound}
// sndPlaySound(MS.Memory, SND_MEMORY or SND_SYNC);
PlaySound(MS.Memory, 0, SND_MEMORY or SND_SYNC);
MS.Free;
end;
end;
end.
wBitsPerSample := $0010;
CapRaff a écrit::Nous avons enfin trouvé l'antimoustiques de nos rêves !
Retourner vers La tribune libre
Utilisateurs parcourant ce forum : Aucun utilisateur enregistré et 1 invité