2

I have raw data:

x-values y-values

x being the time domain. Sample rate is 8000 Hz.

I have plotted them in a sine wave, but can't seem to find any way to convert that into audio form.

Can someone guide through this process?

alpereira7
  • 1,522
  • 3
  • 17
  • 30
Saif Ali
  • 429
  • 5
  • 23

1 Answers1

4

If x is the time domain, you don't really need it since you have Fs = 8000 Hz.

y is your data, you can try to use audiowrite to convert it to an audiofile.

We don't know exactly how your data is encoded, so you will probably need to do some work.

For example, it could be

audiowrite('audioFile.wav`, y, Fs);
alpereira7
  • 1,522
  • 3
  • 17
  • 30
  • 1
    Thanks, I got it done but I have used 1000 values from y as it's clear x is of no use here so it made a file of 1 second. I want it sound longer. – Saif Ali Feb 18 '19 at 11:43
  • 1
    @SaifAli If you have 1000 values at 8000 Hz it should last 1/8 second I don't know how you made it last 1 second. Anyway, if you want to increase the duration of the audio file you can: 1. get more data, 2. repeat your data any time you want `y = [y; y; y; y]`, 3. reduce `Fs` (but you will also change the pitch of your sound). – alpereira7 Feb 18 '19 at 12:19