<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.16.1">
</HEAD>
<BODY>
<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
<BR>
</TD>
</TR>
</TABLE>
Hi,<BR>
<BR>
I am running a .mp3 file using 'xine' without any issues on my Fedora Core 8 machine.<BR>
<BR>
I am reading /dev/dsp and storing it in some file.<BR>
i.e. cat /dev/dsp > musicfile<BR>
<BR>
Now I am stopping 'xine' and then writing 'musicfile' to /dev/dsp.<BR>
i.e. cat musicfile > /dev/dsp<BR>
<BR>
In this case I can hear the music but with a lot of noise in it.<BR>
Is there any way I can remove/reduce this noise from 'musicfile'?<BR>
<BR>
I also tried following program (it records the voice and plays it immediately) that I got from net to understand how to write to /dev/dsp but it does not seem to record my voice and hence plays nothing and there is noise only.<BR>
<BR>
-------------------------------------------------------<BR>
#include <unistd.h><BR>
#include <fcntl.h><BR>
#include <sys/types.h><BR>
#include <sys/ioctl.h><BR>
#include <stdlib.h><BR>
#include <stdio.h><BR>
#include <linux/soundcard.h><BR>
<BR>
#define LENGTH 3    /* how many seconds of speech to store */<BR>
#define RATE 8000   /* the sampling rate */<BR>
#define SIZE 8      /* sample size: 8 or 16 bits */<BR>
#define CHANNELS 1  /* 1 = mono 2 = stereo */<BR>
<BR>
/* this buffer holds the digitized audio */<BR>
unsigned char buf[LENGTH*RATE*SIZE*CHANNELS/8];<BR>
<BR>
int main()<BR>
{<BR>
    int fd; /* sound device file descriptor */<BR>
    int arg;    /* argument for ioctl calls */<BR>
    int status;   /* return status of system calls */<BR>
<BR>
    /* open sound device */<BR>
    fd = open("/dev/dsp", O_RDWR);<BR>
    if (fd < 0) {<BR>
        perror("open of /dev/dsp failed");<BR>
        exit(1);<BR>
    }<BR>
<BR>
    /* set sampling parameters */<BR>
    arg = SIZE;    /* sample size */<BR>
    status = ioctl(fd, SOUND_PCM_WRITE_BITS, &arg);<BR>
    if (status == -1)<BR>
        perror("SOUND_PCM_WRITE_BITS ioctl failed");<BR>
    if (arg != SIZE)<BR>
        perror("unable to set sample size");<BR>
<BR>
    arg = CHANNELS;  /* mono or stereo */<BR>
    status = ioctl(fd, SOUND_PCM_WRITE_CHANNELS, &arg);<BR>
    if (status == -1)<BR>
        perror("SOUND_PCM_WRITE_CHANNELS ioctl failed");<BR>
    if (arg != CHANNELS)<BR>
        perror("unable to set number of channels");<BR>
<BR>
    arg = RATE;    /* sampling rate */<BR>
    status = ioctl(fd, SOUND_PCM_WRITE_RATE, &arg);<BR>
    if (status == -1)<BR>
        perror("SOUND_PCM_WRITE_WRITE ioctl failed");<BR>
<BR>
    while (1) { /* loop until Control-C */<BR>
        printf("Say something:\n");<BR>
        status = read(fd, buf, sizeof(buf)); /* record some sound */<BR>
        if (status != sizeof(buf))<BR>
            perror("read wrong number of bytes");<BR>
        printf("You said:\n");<BR>
        status = write(fd, buf, sizeof(buf)); /* play it back */<BR>
        if (status != sizeof(buf))<BR>
            perror("wrote wrong number of bytes");<BR>
        /* wait for playback to complete before recording again */<BR>
        status = ioctl(fd, SOUND_PCM_SYNC, 0);<BR>
        if (status == -1)<BR>
            perror("SOUND_PCM_SYNC ioctl failed");<BR>
    }<BR>
}<BR>
---------------------------------------------------------------------------------------<BR>
Regards,<BR>
Girish
<p>DISCLAIMER
==========
This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails.</p>
</BODY>
</HTML>