473,395 Members | 1,905 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Can I use a byte array for sound files?

I am using MCI (winmm.dll) to read, record and playback sound. For
now, I am doing this with disk files instead of realtime doing it
straight from the memory. If I want to stream/relay/transmit this
sound (file) on a Windows socket (not using FTP but TCP), can I read
the file into a byte array? Because if it is possible then I can send
it on the socket but the problems I foresee are:

How will I repack it into the file. Will just reading back the byte
array into a file with the same extention work? I mean, say, I have a
..wav file and I read that into a byte array. Then I prefix some header
of my own containing the file name, the type and size etc. and send
this message on a socket, then at the other end, I read this header
and the following byte array and read it back into a file with the
same name and extention, will it be okay or it'll just be
gobbledegook?

How do they stream sound on the Internet otherwise?
Nov 14 '05 #1
2 4297
Sathyaish wrote:
I am using MCI (winmm.dll) to read, record and playback sound. For
now, I am doing this with disk files instead of realtime doing it
straight from the memory. If I want to stream/relay/transmit this
sound (file) on a Windows socket (not using FTP but TCP), can I read
the file into a byte array? Because if it is possible then I can send
it on the socket but the problems I foresee are:

How will I repack it into the file. Will just reading back the byte
array into a file with the same extention work? I mean, say, I have a
.wav file and I read that into a byte array. Then I prefix some header
of my own containing the file name, the type and size etc. and send
this message on a socket, then at the other end, I read this header
and the following byte array and read it back into a file with the
same name and extention, will it be okay or it'll just be
gobbledegook?

How do they stream sound on the Internet otherwise?


This has nothing do to with C FCOL. Use Google-degook before asking
questions.

Case

Nov 14 '05 #2
Sound and sockets are off-topic in comp.lang.c but there are some
issues here that are on-topic.
I am using MCI (winmm.dll) to read, record and playback sound. For
now, I am doing this with disk files instead of realtime doing it
straight from the memory. If I want to stream/relay/transmit this
sound (file) on a Windows socket (not using FTP but TCP), can I read
the file into a byte array?
You can read *ANY* readable file into a byte array (well, in C it's
called a char array) no matter what its format. What you do with
it after that is up to you.
Because if it is possible then I can send
it on the socket but the problems I foresee are:

How will I repack it into the file. Will just reading back the byte
array into a file with the same extention work?
Reading the file into a char array, then writing it back should
work to make a copy of the file, barring problems like running out
of disk space, permissions, bad sectors, etc. The extension is not
relevant to C. Nor is the fact that this file allegedly contains
sound.
etc. I mean, say, I have a
.wav file and I read that into a byte array. Then I prefix some header
of my own containing the file name, the type and size etc. and send
this message on a socket, then at the other end, I read this header
and the following byte array and read it back into a file with the
same name and extention, will it be okay or it'll just be
gobbledegook?
What's the format expected for the file? (Does the file have fields
in it that are byte-order-sensitive, like, say, a 24-bit field for
sampling frequency?) What's the format expected over the socket?
If you add a header before sending it you should be prepared to
remove it before writing the file. Treating the file as a byte
array shouldn't add any MORE platform-dependencies than there were
in the original file.

When transferring files over sockets (also true of reading blocks
of data from the keyboard, and disk files, but it may be a bit more
erratic with sockets): fread() may return chunks of data that are
not the same size as the chunks you wrote. (e.g. you wrote two
500-byte blocks; you might get them back as three 300-byte blocks
and one 100-byte block.) Be prepared to handle this situation.
*USE* the amount of data read that fread() returns, don't assume
you got all you asked for, and don't assume that if you got a short
block that it's the last one.
How do they stream sound on the Internet otherwise?


I don't know what format they use for streaming sound, but
you probably have to stream licenses at the same time, and
remove the CSS encryption.

Gordon L. Burditt
Nov 14 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Tim Shih | last post by:
Hi, I'm looking for a way to remotely pass bitmaps and soundfiles via remoting. I have a class which contains a bitmap and I can easily access it remotely as long as I do not set a value for the...
1
by: Andre Ranieri | last post by:
I'm having trouble programatically inserting an Excel file into an Image column in our CRM package's SQL 2000 database. The function appears to work ok, but when I attempt to access the file through...
2
by: Ron | last post by:
Hello, I am trying to read a list of files from an FTP server (mainframe) to a byte array using sockets as follows, but not getting all the files in a given directory: private readonly static...
1
by: Angel Filev | last post by:
Hi everyone, I am trying to store a file as a binary array in an "image" field in SQL Server 2000 database. It works OK except for the ".PDF" files, which I believe get corrupted in the process...
5
by: Robin Tucker | last post by:
I need to marshal an IntPtr (which I've got from GlobalLock of an HGLOBAL) into a byte array. I know the size of the array required and I've got a pointer to the blob, but I can't see how to copy...
2
by: Jon | last post by:
We have a regular ASP website that uses the third party ASPUpload control for uploading files. Those files are in the byte array format, ready to be stored into SQL Server. I need to transfer that...
1
by: andreas | last post by:
Hi, with imagelist it is possible to hide pictures files in a program is there a possibility to hide sound files (like wav) in a vb.net program? thanks for any response
5
by: news.microsoft.com | last post by:
Hello, what is the most performant size for the byte array for reading/writing using 2 filestreams? example code: Dim bytearrayinput(4095) As Byte Dim rdlen As Long = 0 Dim totlen As Long...
0
by: lovecarole | last post by:
hi, i am the student who should write a program about reading wav file and do the DFT. actually i don't know how to read data of the wav song and save it into the array... if i want to read...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.