Hi All,
I have been struggling with this for weeks now and I just can't get my
head around it. I am trying to convert this procedure to VB.NET. In
particular I am having problems with the CopyMemory and ZeroMemory
calls. I have been messing around with the Marshal class but just
can't seem to get it to work. Can anybody help me with this please and
also if possible tell me what they did so I can learn from it.
Many Thanks,
Declare Sub FillMemory Lib "kernel32.d ll" Alias "RtlFillMem ory" (ByRef
Destination As Object, ByVal length As Integer, ByVal Fill As Byte)
Declare Sub CopyMemory Lib "Kernel32" Alias "RtlMoveMem ory" (ByRef
hpvDest As Object, ByRef hpvSource As Object, ByVal cbCopy As Integer)
Declare Sub ZeroMemory Lib "kernel32.d ll" Alias "RtlZeroMem ory"
(ByRef Destination As Object, ByVal length As Integer)
<StructLayout(L ayoutKind.Seque ntial, CharSet:=CharSe t.Ansi)> Structure
WAVEHDR
Dim lpData As Integer
Dim dwBufferLength As Integer
Dim dwBytesRecorded As Integer
Dim dwUser As Integer
Dim dwFlags As Integer
Dim dwLoops As Integer
Dim lpNext As Integer
Dim Reserved As Integer
End Structure
Public g_PhoneOutHdr(N UM_BUFFERS) As WAVEHDR
Public Sub PlayWaveChunk(B yRef NumChunksToPlay As Short, ByRef
StartingBuffer As Integer, ByRef hOutputDevice As Integer, ByRef
FileAsInput As Boolean)
Dim i As Short
For i = 1 To NumChunksToPlay
'we DO have a full buffer left
ReDim SpeakerArray(BU FFER_SIZE - 1)
If (MessagePlaying Position + BUFFER_SIZE <=
(TotalFileLengt h + 1)) Then
'lets see if we are using input from a file or from
SAPI memory stream
If FileAsInput Then
'we are using wave input from a file, lets load the
data into an array
FileGet(fFile, SpeakerArray,
MessagePlayingP osition)
'lets copy the array bytes to our wave output
buffer area
CopyMemory(g_Ph oneOutHdr(Start ingBuffer).lpDa ta,
SpeakerArray(0) , BUFFER_SIZE)
Else
'we are using wave input that has been generated
via SAPI internally
CopyMemory(g_Ph oneOutHdr(Start ingBuffer).lpDa ta,
MemStream(Messa gePlayingPositi on), BUFFER_SIZE)
End If
g_PhoneOutHdr(S tartingBuffer). dwBufferLength =
BUFFER_SIZE
'lets check to see if we are done, this would be very
rare to finish exactly
'on a buffer boundry. usually we will have one last
chunk to play that will be
'smaller than our buffer size.
If MessagePlayingP osition + BUFFER_SIZE =
(TotalFileLengt h + 1) Then
'we will use this to determine when we are finished
playing
g_PhoneOutHdr(S tartingBuffer). dwUser =
EndofWaveFile
If FileAsInput Then
FileClose(fFile )
End If
i = NumChunksToPlay + 1
Else
g_PhoneOutHdr(S tartingBuffer). dwUser =
StartingBuffer
End If
play_audio_buff er(g_PhoneOutHd r(StartingBuffe r),
hOutputDevice)
MessagePlayingP osition = MessagePlayingP osition +
BUFFER_SIZE
'lets set the wave playing progress bar value
fmain.DefInstan ce.pbPlayingWav e.Value =
MessagePlayingP osition
StartingBuffer = StartingBuffer + 1
If StartingBuffer > NUM_BUFFERS - 1 Then
StartingBuffer = 0
End If
Else
'*** this section handles the last buffer chunk that is
smaller than our
'buffer size
If MessagePlayingP osition < TotalFileLength + 1 Then
'we've got one last chunk of data to play
g_PhoneOutHdr(S tartingBuffer). dwUser =
EndofWaveFile
If FileAsInput Then
'we do NOT have a full buffer of data left to
play
ReDim SpeakerArray((T otalFileLength -
MessagePlayingP osition) - 1)
FileGet(fFile, SpeakerArray,
MessagePlayingP osition)
ZeroMemory(g_Ph oneOutHdr(Start ingBuffer).lpDa ta, BUFFER_SIZE)
CopyMemory(g_Ph oneOutHdr(Start ingBuffer).lpDa ta, SpeakerArray(0) ,
TotalFileLength - MessagePlayingP osition)
Else
ZeroMemory(g_Ph oneOutHdr(Start ingBuffer).lpDa ta, BUFFER_SIZE)
CopyMemory(g_Ph oneOutHdr(Start ingBuffer).lpDa ta,
MemStream(Messa gePlayingPositi on), TotalFileLength -
MessagePlayingP osition)
End If
g_PhoneOutHdr(S tartingBuffer). dwBufferLength =
BUFFER_SIZE
play_audio_buff er(g_PhoneOutHd r(StartingBuffe r),
hOutputDevice)
MessagePlayingP osition = MessagePlayingP osition +
BUFFER_SIZE
If FileAsInput Then
FileClose(fFile )
End If
i = NumChunksToPlay + 1
End If
End If
Next i
End Sub 0 2057 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Naresh |
last post by:
I have been having a problem and I don't know where to go for help. The microsoft support is only for a fees. Can anyone at all please at least point to a site or some place where I can hope for some enlightment
My problem
I am using Windows XP and had installed .NET 2000. I then downloaded the .NET framework 1.1 from teh microsoft site and installed it and then rebooted the machine. When I open the Internet manager console, I find that my web...
|
by: Rob R. Ainscough |
last post by:
This is more of a conceptual question:
1. More and more companies are using VPN's and locking out internet
connectivity (for a host of reasons, security, productivity, etc.).
2. ASP.NET requires a web server and has more layers than a .NET Windows
application
3. a .NET windows app .DLL's and .EXEs are very small
So which is better, offer a Windows .NET component ("managed") that can be
downloaded installed from a web site or...
|
by: Jeannie |
last post by:
Hello group!
I'm in Europe, traveling with my laptop, and I don't any compilers
other than Borland C++ 5.5. available. I also don't have any manuals
or help files available. Sadly, more crippling problems! I never used
C++ much, so, I don't remember commands or fuctions well. My questions
are simple. I posted the DOS window output so you can see the Borland
C++ version I am using:
E:\TZ>bcc32 file2
|
by: TN Bella |
last post by:
Hi,
I am trying to get my compare validator to fire properly...Since I have
panels the validator wouldn't work properly, the app would fire right
but would insert the data regardless and the user couldn't fix an error
if they had an error. So I added another sub and fixed the panels, but
the compare validator still doesn't work right.
Right now the validator pops up with the error that the two values
(txtAcctAmtSum and txtInvAmt) are...
|
by: Alan Silver |
last post by:
Hello,
This is NOT a troll, it's a genuine question. Please read right
through to see why.
I have been using Vusual Basic and Classic ASP for some years, and
have now started looking at ASP.NET. At first glance, it looks
excellent, albeit nothing that couldn't have been done to Classic ASP.
I have been through a few tutorials and was impressed with how quickly
you can get database info onto a page.
| |
by: pemo |
last post by:
Is C really portable? And, apologies, but this is possibly a little OT?
In c.l.c we often see 'not portable' comments, but I wonder just how
portable C apps really are.
I don't write portable C code - *not only* because, in a 'C sense', I
|
by: Chrisjc |
last post by:
I am not good at VB and I am taking a class for it at ITT... I am doing a program chanllenge and really really need help it is due today... and I am not good at this at all... could some one please look over my started work and help me make it work... or if you could someone that is really good at this could you be able to just make it work... I had to take this class and really I dont like VB.... I am trying to learn php/MySQL you can see if...
|
by: mike3 |
last post by:
Hi.
I seem to have made some progress on finding that bug in my program. I
deactivated everything in the bignum package that was used except for
the returning of BigFloat objects. I even crippled all the
constructors. So now all the operations and constructors that were
used do is just return BigFloats but no memory is actually accessed at
any point, nor is any allocated. However, when I reenable those parts
of the constructor that...
|
by: Dr Mephesto |
last post by:
Hi!
I would like to create a pretty big list of lists; a list 3,000,000
long, each entry containing 5 empty lists. My application will append
data each of the 5 sublists, so they will be of varying lengths (so no
arrays!).
Does anyone know the most efficient way to do this? I have tried:
list = ,,,,] for _ in xrange(3000000)]
|
by: Chris M. Thomasson |
last post by:
I use the following technique in all of my C++ projects; here is the example
code with error checking omitted for brevity:
_________________________________________________________________
/* Simple Thread Object
______________________________________________________________*/
#include <pthread.h>
extern "C" void* thread_entry(void*);
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |