Thread: [Dev-C++] New to the list, and a quick question
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Philip B. <phi...@pb...> - 2007-01-05 19:34:43
|
Hello everyone. My name is Philip Bennefall, I am an audio producer and game programmer = from Sweden. I am just getting into C++, before now I've been working = with high level languages. But lately I've started to feel that they = simply are not good enough for my needs, they limit me too much in what = I can do. I'm a complete beginner at the actual C++ language, although I = know programming well. My first question is, in Dev C++, is it possible = to pack for example a sound file into your executable and then access it = directly from memory inside of the application? That is, without ever = extracting it on to the users harddrive. That way, noone will be able to = see the file unless they know how to disassemble executables which is = certainly beyond me. Basically I just want to put the file in the = executable together with my code and be able to access it directly with = a memory address or perhaps a buffer pointer. If anyone can answer this, I'd be very glad. Thanks in advance. Regards Philip Bennefall |
|
From: Per W. <pw...@ia...> - 2007-01-05 19:53:56
|
Actually, C++ is a high-level language too even if some have claimed the
precursor language C to be "high-level assembly" :)
Yes, it is possible to store binary data within the application. It can
bedone in a number of ways.
One common way is to use a little utility application that takes the
binary resource and converts to an array of hex data that is then compiled
into the binary like:
-----
// sound_cannonshot.cpp
unsigned char wavesound_cannonshot[] = {
0x10,0x20,0x30,...
};
unsigned wavesound_size = sizeof(wavesound_cannonshot);
-----
Another approach is to store the sound as a binary resource, the same way
that Windows applications stores icons and bitmaps.
If using the resource file, then it is very easy to extract the data using
an resource editor on your executable. Even if the resource file is
compiled, the resource editor will display a list of all items in the file
- what type they are and what identifier to access them.
If storing the sound in the source, a normal tool can not extract it.
However, writing a tiny app that just feeds the full exe file through the
sound card may probably play the sound, unless the sound was incorrectly
aligned, i.e. the low byte of one 16-bit sample got played together with
the high byte of the next 16-bit sample, in which case it would probably
just sound like noise.
If it is every more important to protect the data, you can combine any of
the above methods - or the use of external sound files - with encryption.
Load file, decrypt, play. The openssl project contains readily available
code to encrypt/decrypt streams of data using government-approved
algorithms.
Alas, even with encryption, you will only be able to protect unmixed raw
sounds. The actual output to the sound card can normally alwasy be
retrieved, since the Windows sound system have a lot of layers where
third-party filters may install and rip the data.
/Per W
On Fri, 5 Jan 2007, Philip Bennefall wrote:
>
> Hello everyone.
>
> My name is Philip Bennefall, I am an audio producer and game programmer
> from Sweden. I am just getting into C++, before now I've been working
> with high level languages. But lately I've started to feel that they
> simply are not good enough for my needs, they limit me too much in what
> I can do. I'm a complete beginner at the actual C++ language, although I
> know programming well. My first question is, in Dev C++, is it possible
> to pack for example a sound file into your executable and then access it
> directly from memory inside of the application? That is, without ever
> extracting it on to the users harddrive. That way, noone will be able to
> see the file unless they know how to disassemble executables which is
> certainly beyond me. Basically I just want to put the file in the
> executable together with my code and be able to access it directly with
> a memory address or perhaps a buffer pointer.
>
> If anyone can answer this, I'd be very glad.
>
> Thanks in advance.
>
> Regards
> Philip Bennefall
|
|
From: Pedro P. <eje...@ya...> - 2007-01-11 17:55:53
|
Hello;=0A=0A Is not advisable to include a complete audio file in your pr= ogram, maybe if is a small file you can include it as a resource file.=0A= =0A I think the best you can do is to pack it in a file in some format y= ou desire (*.dat), unpack it and use it as desire. (Tip: You can apply a co= mpress format leaving the .dat extension and then encrypt it, that helps to= o).=0A=0A=0A =0A___________________________________________________________= _________________________=0AAny questions? Get answers on any topic at www.= Answers.yahoo.com. Try it now. |
|
From: Per W. <pw...@ia...> - 2007-01-11 18:42:43
|
Note that sound is very hard to compress, and for most applications it isn't meaningful to spend any time to compress/decompress it. The only situations where compression is important is when used in flash memory of small hand-held devices, or if transmitted over a bandwidth-limited media, such as using a GPRS phone. Cmpiling audio or images into an application is quite often done, and works very well. By having the information in the exe file - or even better in one or more dll files - the OS will be able to throw away the information in case of a mermory contention. If the information is read in from a data file (read in, instead of memory-mapped), the OS must swap out the information so that it can restore the information later without letting the application know about it. Information stored in resource files, the exe file or a dll file does not need to be swapped, since the OS specifically knows how to load the information on demand directly from the original source. /Per W On Thu, 11 Jan 2007, Pedro Perez wrote: > Hello; > > Is not advisable to include a complete audio file in your program, maybe if is a small file you can include it as a resource file. > > I think the best you can do is to pack it in a file in some format you desire (*.dat), unpack it and use it as desire. (Tip: You can apply a compress format leaving the .dat extension and then encrypt it, that helps too). > > > > ____________________________________________________________________________________ > Any questions? Get answers on any topic at www.Answers.yahoo.com. Try it now. > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
|
From: Roger F. <ra...@ha...> - 2007-01-12 02:21:24
|
Aloha from honolulu,
If you use a .wav file this is usually uncompressed audio. There
are several compressed audio formats .mp3, .m4a, etc. Microsoft and
Apple each have their own formats that Windows Media Player and iTunes
use. I'm not sure about Unix/Linux, but the point is audio compression
formats exist and deliver reasonable results. Don't try to compress a
.wav file into a .zip and expect to enjoy the listening experience.
(Although that isn't based on my experience--I've never tried it.)
In professional recording the trend now is to record the tracks at
the higest resolution, now 24-bit/196KHz sample rate. Then mix to
stereo file (at same res) then downsample to meet spec for various
formats. Audio DVDs are 24-bit/96KHz and CDs are 16-bit/44.1KHz. Audio
for video is usually 16-bit/48KHz. Note that none of this is
compressed, it is just using less of the original information.
MP3 (MPEG-1 Audio Layer 3) on the other hand is defined as a lossy
compression format where "inaudible" data is removed from the audio
file. Look up "MP3" in Wikipedia http://en.wikipedia.org/wiki/MP3 the
article has information on the various formats in use today.
The compression ratios are quite impressive, but you must choose
what type of compression you use, based on the audio material involved.
Speech can be compressed the most. Loud, hard rock and roll music can
handle a lot of compression. Delicate classical music with large
dynamic range will suffer the most from compression. If you have the
time and tools, run the audio through an oscilloscope and compare
uncompressed to compressed.
Hope this is helpful.
Aloha,
Roger Furer
Per Westermark wrote:
> Note that sound is very hard to compress, and for most applications it
> isn't meaningful to spend any time to compress/decompress it.
>
> The only situations where compression is important is when used in flash
> memory of small hand-held devices, or if transmitted over a
> bandwidth-limited media, such as using a GPRS phone.
>
> Cmpiling audio or images into an application is quite often done, and
> works very well. By having the information in the exe file - or even
> better in one or more dll files - the OS will be able to throw away the
> information in case of a mermory contention. If the information is read in
> from a data file (read in, instead of memory-mapped), the OS must swap out
> the information so that it can restore the information later without
> letting the application know about it. Information stored in resource
> files, the exe file or a dll file does not need to be swapped, since the
> OS specifically knows how to load the information on demand directly
> from the original source.
>
> /Per W
>
> On Thu, 11 Jan 2007, Pedro Perez wrote:
>
>
>>Hello;
>>
>> Is not advisable to include a complete audio file in your program, maybe if is a small file you can include it as a resource file.
>>
>> I think the best you can do is to pack it in a file in some format you desire (*.dat), unpack it and use it as desire. (Tip: You can apply a compress format leaving the .dat extension and then encrypt it, that helps too).
>>
>>
>>
>>____________________________________________________________________________________
>>Any questions? Get answers on any topic at www.Answers.yahoo.com. Try it now.
>>
>>-------------------------------------------------------------------------
>>Take Surveys. Earn Cash. Influence the Future of IT
>>Join SourceForge.net's Techsay panel and you'll get the chance to share your
>>opinions on IT & business topics through brief surveys - and earn cash
>>http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>>_______________________________________________
>>Dev-cpp-users mailing list
>>Dev...@li...
>>TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
>>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>>
>
>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|
|
From: Per W. <pw...@ia...> - 2007-01-12 02:45:27
|
Note that non-lossy audio compression (I'm definitely not talking about zip :) or similar) have a hard time giving more than 30-50% compression for music. Software that needs to be delivered with audio samples often requires non-lossy audio (instrument samplings for a sequencer software) or have too small sample files for it to be worth it to bother with mp3 or similar (informational/error sounds or speech messages). Consider for example an application I developed at a previous employer. It was delivered with alarm messages. Let's assume 50 different alarm messages, each about 3 seconds long. 150 seconds times 22kHz 16-bit mono is less than 7MB total size. The need for sound compression would in this case be quite small, and I think this would be representable for quite a large percentage of applications that are distributed with sound data. The other end of the spectrum is of course high-end sequencer software, that might be delivered with many GB of sound samples, but then the requirements are often 24-bit non-lossy audio. While multimedia players make good use of (lossy) compressed audio, I really don't think they are representative of software that are distributed with audio. You get the player without any sound clips, and you then collect your music separately. /Per W On Thu, 11 Jan 2007, Roger Furer wrote: > Aloha from honolulu, > If you use a .wav file this is usually uncompressed audio. There > are several compressed audio formats .mp3, .m4a, etc. Microsoft and > Apple each have their own formats that Windows Media Player and iTunes > use. I'm not sure about Unix/Linux, but the point is audio compression > formats exist and deliver reasonable results. Don't try to compress a > .wav file into a .zip and expect to enjoy the listening experience. > (Although that isn't based on my experience--I've never tried it.) > In professional recording the trend now is to record the tracks at > the higest resolution, now 24-bit/196KHz sample rate. Then mix to > stereo file (at same res) then downsample to meet spec for various > formats. Audio DVDs are 24-bit/96KHz and CDs are 16-bit/44.1KHz. Audio > for video is usually 16-bit/48KHz. Note that none of this is > compressed, it is just using less of the original information. > MP3 (MPEG-1 Audio Layer 3) on the other hand is defined as a lossy > compression format where "inaudible" data is removed from the audio > file. Look up "MP3" in Wikipedia http://en.wikipedia.org/wiki/MP3 the > article has information on the various formats in use today. > The compression ratios are quite impressive, but you must choose > what type of compression you use, based on the audio material involved. > Speech can be compressed the most. Loud, hard rock and roll music can > handle a lot of compression. Delicate classical music with large > dynamic range will suffer the most from compression. If you have the > time and tools, run the audio through an oscilloscope and compare > uncompressed to compressed. > Hope this is helpful. > Aloha, > Roger Furer > > Per Westermark wrote: > > > Note that sound is very hard to compress, and for most applications it > > isn't meaningful to spend any time to compress/decompress it. > > > > The only situations where compression is important is when used in flash > > memory of small hand-held devices, or if transmitted over a > > bandwidth-limited media, such as using a GPRS phone. > > > > Cmpiling audio or images into an application is quite often done, and > > works very well. By having the information in the exe file - or even > > better in one or more dll files - the OS will be able to throw away the > > information in case of a mermory contention. If the information is read in > > from a data file (read in, instead of memory-mapped), the OS must swap out > > the information so that it can restore the information later without > > letting the application know about it. Information stored in resource > > files, the exe file or a dll file does not need to be swapped, since the > > OS specifically knows how to load the information on demand directly > > from the original source. > > > > /Per W > > > > On Thu, 11 Jan 2007, Pedro Perez wrote: > > > > > >>Hello; > >> > >> Is not advisable to include a complete audio file in your program, maybe if is a small file you can include it as a resource file. > >> > >> I think the best you can do is to pack it in a file in some format you desire (*.dat), unpack it and use it as desire. (Tip: You can apply a compress format leaving the .dat extension and then encrypt it, that helps too). > >> > >> > >> > >>____________________________________________________________________________________ > >>Any questions? Get answers on any topic at www.Answers.yahoo.com. Try it now. > >> > >>------------------------------------------------------------------------- > >>Take Surveys. Earn Cash. Influence the Future of IT > >>Join SourceForge.net's Techsay panel and you'll get the chance to share your > >>opinions on IT & business topics through brief surveys - and earn cash > >>http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > >>_______________________________________________ > >>Dev-cpp-users mailing list > >>Dev...@li... > >>TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > >>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > >> > > > > > > > > ------------------------------------------------------------------------- > > Take Surveys. Earn Cash. Influence the Future of IT > > Join SourceForge.net's Techsay panel and you'll get the chance to share your > > opinions on IT & business topics through brief surveys - and earn cash > > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > _______________________________________________ > > Dev-cpp-users mailing list > > Dev...@li... > > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |