473,394 Members | 1,774 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,394 software developers and data experts.

audio file problem

36
hello !

i m reading a wav file by int b=ins.read(); and writing b on other wav file by
outs.write(b); in a loop until b==-1
where
InputStream ins = new FileInputStream("C:/audio.wav");
OutputStream outs = new FileOututStream(new File("c:/audio1.wav"));
its playing
but when i write something to output file in byte form having some value from my own it does not play
eg. byte b[] = new byte[1];
and b[0] having some value 123 and writing b by
outs.write(b); at some place and copying other as it is.
it show an error when on playing ie. cannot create audio stream from input stream
what is the problem with this? can anyone help me out?
Oct 9 '08 #1
5 1860
myusernotyours
188 100+
Hi,

We cannot help you out if we have to struggle to understand what you are trying to do.

Just put your question nicely and put the code between tags then it will be easier for all of us.

Regards,

Alex.
Oct 9 '08 #2
pankajs
36
i m working on embedding a text message in a wav file. To do it we have to first read the audio file(wav) , there is method a read() to read the file and a method write(b) to write a audio file where b is a byte having some data.
Here is the code

Expand|Select|Wrap|Line Numbers
  1. public void messagencode(String message,File file) throws
  2.   Exception
  3.   {
  4.       len= message.length();
  5.       char chmess[] = new char[len];
  6.       message.getChars(0,len,chmess,0);
  7.       InputStream ins = new FileInputStream(file);
  8.       OutputStream outs = new FileOutputStream(new File("c:/steged.wav"));
  9.       byte b[]=new byte[1];
  10.       for(int i=0;i<len+1;i++)
  11.       {
  12.  
  13.               String slen=String.valueOf(chmess[i-1]);
  14.              byte bmes[]=slen.getBytes();
  15.               outs.write(bmes);
  16.                int n=ins.read(b);
  17.       }
  18.       while(true)
  19.       {
  20.       int i=ins.read();
  21.       if(i==-1) break;
  22.       outs.write(i);
  23.       }
  24.       ins.close();
  25.       outs.close();
  26.   }

in this code firstly byte form a text message is written on steged.wav, then in the while(true) loop what is being done is that audio file is copied in steged.wav


But the problem is that when try to play steged.wav it shows an error ie.
could not create audio stream from input stream


But second thing is that when we only copied a wav file just applying while loop as above, it playing
Oct 9 '08 #3
pankajs
36
i m working on embedding a text message in a wav file. To do it we have to first read the audio file(wav) , there is method a read() to read the file and a method write(b) to write a audio file where b is a byte having some data.
Here is the code

Expand|Select|Wrap|Line Numbers
  1. public void messagencode(String message,File file) throws
  2.   Exception
  3.   {
  4.       len= message.length();
  5.       char chmess[] = new char[len];
  6.       message.getChars(0,len,chmess,0);
  7.       InputStream ins = new FileInputStream(file);
  8.       OutputStream outs = new FileOutputStream(new File("c:/steged.wav"));
  9.       byte b[]=new byte[1];
  10.       for(int i=0;i<len;i++)
  11.       {
  12.  
  13.               String slen=String.valueOf(chmess[i]);
  14.              byte bmes[]=slen.getBytes();
  15.               outs.write(bmes);
  16.                int n=ins.read(b);
  17.       }
  18.       while(true)
  19.       {
  20.       int i=ins.read();
  21.       if(i==-1) break;
  22.       outs.write(i);
  23.       }
  24.       ins.close();
  25.       outs.close();
  26.   }

in this code firstly byte form a text message is written on steged.wav, then in the while(true) loop what is being done is that audio file is copied in steged.wav


But the problem is that when try to play steged.wav it shows an error ie.
could not create audio stream from input stream


But second thing is that when we only copied a wav file just applying while loop as above, it playing
Oct 9 '08 #4
pankajs
36
read the second one th
Oct 9 '08 #5
myusernotyours
188 100+

But the problem is that when try to play steged.wav it shows an error ie.
could not create audio stream from input stream


But second thing is that when we only copied a wav file just applying while loop as above, it playing
It seems you are messing up the file format while appending the message. Usually such files have specific formats and you can't just append data arbitrarily.

You will need to know the file format before you can tinker with the file. Just search google for the format specification.

Regards,

Alex.
Oct 9 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Bruce Bon | last post by:
The class below is intended to play a Sun audio file (.au) in the background while the main thread, which is servicing a GUI, continues without impact. It doesn't work. For a sound file that...
1
by: Ron Provost | last post by:
Hello, I'm developing a piece of software to assist illiteraate adults to learn to read. I'm trying to figure out how, if possible, to make audio playback asynchrnous but still controllable. ...
2
by: hzgt9b | last post by:
Using VS2003, VB.NET, BACKGROUND I have a window forms based application that will be distributed and executed directly from CD media. The app contains a TreeView control and a WebBroswer...
4
by: hzgt9b | last post by:
Using VS 2003, VB.NET and/or ASP.NET 2.0, BACKGROUND I have a window forms based application that contains a TreeView control and a WebBroswer (AxSHDocVw.AxWebBrowser) control. The TreeView is...
13
by: anil.rita | last post by:
When the user chooses an AV file to play, based upon the type of file, I want to use the default installed media player to play it. I am wondering if this is a good way - any alternatives,...
7
by: Udhay | last post by:
How to get the frequency of an audio file and how to separate the low and high frequency of an audio file
2
by: peteinglastonbury | last post by:
I'd be most grateful if someone would help me. I hope I'm in the right forum (apologies if not) - I'm not sure whether my problem is CGI or Javascript related. I found a script called...
1
Dököll
by: Dököll | last post by:
Greetings, Good buddies! I am for the first time, since I started learning VB, going to build an application I wanted to build for my first son, a language and activities program that will allow...
1
by: =?Utf-8?B?Qm9iQWNoZ2lsbA==?= | last post by:
I am using Windows Media Player to play my half second audio files one after the other using the code below... My problem comes when I play a second audio file immediately after the first one...
8
by: raylopez99 | last post by:
I have the latest version of Visual Studio 2008 Professional, which allows you to create resource files (this is the .resx file, no?), unlike the Express version, which does not. I am trying to...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.