Thanx for all the response...I always used SndPlaySound in the
past as well but now the documentation recommends PlaySound alone, but
for either I will check out what parameters will allow it to be stored
in Memory.
        As for Delphi 2007, I've not been experiencing any problems with
the Help System that you describe, but I AM having one where a
particular component set failed to set up it's files in it properly.
Problems that I experienced in previous versions like slow startups or
not recycling memory properly, and their inability to handle large
projects without constant exceptions and slowing down no longer exist.
I am running a Dual-core Intel chip however, which I didn't have with
D2005 and 6, and it's using both almost equally, so that may have
something to do with it.  All in all, It seems to be the most stable
version since D7. 

from Robert Meek dba "Tangentals Design"
e-mail: [EMAIL PROTECTED]
Freelance Windows Programming for XP and Vista 
Also proud to be a Moderator of the "Delphi-List" at elists.org

"Reality cannot be explained...only enjoyed or endured as your current
perspective allows!"


Hi.

I used in the past 'sndPlaySound'. Do a Google for it to see how to use
it.
I you want to play a simple beep tone you can try this:

procedure MakeSound(Frequency {Hz}, Duration {mSec}: Integer; Volume: 
Byte);    { writes tone to memory and plays it}
VAR
  WaveFormatEx: TWaveFormatEx;
  MS: TMemoryStream;
  i, TempInt, DataCount, RiffCount: integer;
  SoundValue: byte;
  w: 
double;

// omega ( 2 * pi * frequency)
const
  Mono: Word = $0001;
  SampleRate: Integer = 11025; // 8000, 11025, 22050, or 44100
  RiffId: string = 'RIFF';
  WaveId: string = 'WAVE';
  FmtId: string = 'fmt ';
  DataId: string = 'data';
begin
  if Volume> 127 then Volume:= 127;
  if Frequency > (0.6 * SampleRate) then
  begin
    Mesaj(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 := $0008;
    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 := 127 + trunc(Volume * sin(i * w / 
SampleRate));              // wt = w * i / SampleRate
      Write(SoundValue, SizeOf(Byte));
    end;
    sndPlaySound(MS.Memory, SND_MEMORY or SND_SYNC);        << your 
sndPlaySound is here.
    MS.Free;
  end;
end;


But your delay is not because you reload the file (from disk) but it is 
played in asincrone mode.
Try to put a breakpoint at on the sound line, then run step by step and 
you will see that the sound will play later (after few steps).
So I think you need to play that in sync mode, but I THINK that your 
application will hang/freeze while the sound is playing (if it is long).



Second:
Are you sure that Delphi 2007 is so perfect?
I tried it and deleted in 3 days. Boy, I never deleted a software so
quick.
One of the problems (and I can't call it minor) was that the Help system

didn't worked almost at all.
And when it worked it returned only results for that .Net stuff. No 
single Delphi line was there.
And I looked over the Internet. I am not the only one that had a problem

with the help system.
Anyway, that was only one of the serious problems. I will not discuss 
the rest of them here because I will go oftopic.

After I made a purchase in a hurry of D2005 (upgrade from Delphi 7), 
which I never used (everybody knows why) I will test allot a new version

before declaring it worthy.

________________________________

Robert Meek wrote:
> Morning all,
>       It feels great to be back working again, and try as I might I
> simply cannot find any faults with the CodeGear release of Delphi
2007!
> Great job guys!
>       Anyway, my current project involves a groups of methods that
> control a digital clock, up and down Timer, and a Calendar, and
provides
> the user with multiple ways of using sounds and counting procedures
for
> alarms and such.
>       Two areas I wish to ask about.
>       The first is in regards to playing a simple sound file, ( Wav ),
> at one second intervals.  Right now after trying some of the related
> methods and parameters, I'm using
'PlaySound(PChar(SelIntervalWavFile),
> 0, SND_ASYNC);' and a wav file that just plays a beep.  Other methods
> related to this one either cycle out of synch or skip seconds, and
> though this one seems to keep up with my timing event, the first
couple
> beeps play late.  I'm not sure where the majority of the problem lies,
> but I believe it's due to having to load and re-load the file.  Is
there
> anyway of loading such a file into memory before the countdown begins
> and stays there so that this problem is eliminated?  Should I not use
a
> wav file, a simple system beep in place of it to guarantee good
> synching?  Is PlaySound from mmSystem the problem?  Is there a better
> way?  Unless someone has a better solution, I'm thinking now of just
> using the system Beep for the interval sound and then a custom wav
file
> at the end of the timing period.
>       The second question regards the timing method itself.  At
> present I'm using a Clock/Calendar panel from Raize to display for
some
> of the methods and a Raize digital control for simple up/down
counting.
> Either is displayed in place of the other as required at the moment,
but
> the Clock/Calendar has it's own OnTimeExpired event which can be set
> down to 500ms.  For one second timing as displayed on the digital
> control, I'm also using this same event and counting by 2's.  I don't
> necessarily need anything more accurate, but efficient would be the
word
> I would choose.       Is there a better freeware timer component out
> there I haven't found that might help?  And should I keep my timing
> methods in their own thread?
>
>       Lastly, I'm having difficulty with only one set of
> components...those from TMS.  I have the latest update files, 4.3, for
> this version of Delphi, but I'm having a problem trying to compile the
> new packages that is quite odd.  I've already contact them about this
> but so far they only been able to offer the same solutions I've
already
> tried.  There are no registry entries or loose bpl's lying about my
> system, but every time I attempt to compile a dpk or open the entire
> project containing all of them and click Open, I get an error for the
> first dpk which has a filename of TMSd2007.dpk, and then every other
> package as well.  It says, "Unable to access TMSd2007.$$$"  I figure
> that's a temp file it needs to create because none exists with that
> extension in the source code, and I have made sure all directories and
> source has write access.  Could there be a temp dir on my system
> somewhere that it is trying to use?  Any ideas?       
>       
>
> from Robert Meek dba "Tangentals Design"
> e-mail: [EMAIL PROTECTED]
> Freelance Windows Programming for XP and Vista 
> Also proud to be a Moderator of the "Delphi-List" at elists.org
>
> "Reality cannot be explained...only enjoyed or endured as your current
> perspective allows!"
>
>
> _______________________________________________
> Delphi mailing list -> [email protected]
> http://www.elists.org/mailman/listinfo/delphi
>
>   
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to