android
  #1  
Old 01-13-2010, 10:19 AM
Brett_val's Avatar
Brett_val Brett_val is offline
Senior Member
 
Join Date: Jan 2010
Location: The Netherlands
Posts: 636
Default trying to play wave files

Hi,

I'm trying to find a way to play all the wave files I ripped from cds. As you all probably know the X-Fi2 doesn't display PCM 44100Hz stereo 1411Kbps wave files in the library.

I'm not a programmer, but in this forum I found a code to play them through an application, which is

Code:
audio.volume(25);
My_sound = wav.load("sound1.wav");
wav.play(My_sound);
(by Jan_DK)

I put this in Notepad, saved as MAIN.LUA, together with the wave file.
It now looks like this:



When I start the application "music" on the zen it does nothing..

can somebody point out what I am doing wrong?
Reply With Quote

Advertisement [Remove Advertisement]

  #2  
Old 01-13-2010, 10:48 AM
Jan_DK's Avatar
Jan_DK Jan_DK is offline
Junior Member
 
Join Date: Mar 2009
Location: Denmark
Posts: 88
Default

Quote:
Originally Posted by Brett_val View Post
Hi,

When I start the application "music" on the zen it does nothing..
can somebody point out what I am doing wrong?
Hi.

And good thinking, but the X-Fi2 don't have enough RAM
to load and play a "normal" song.

1. The wave file has to 44.100Khz 16bit stereo check that, I don't know if the X-Fi2 can play eg. 48.000Khz.

2. The file size:
I've tried with a 35mb wave file - Not working
tried with a 8mb wave file - Working


Jan_DK

Last edited by Jan_DK; 01-13-2010 at 10:53 AM.
Reply With Quote

  #3  
Old 01-13-2010, 10:50 AM
bzdbbb's Avatar
bzdbbb bzdbbb is offline
X-Fi2 Development Moderator
 
Join Date: Dec 2009
Location: Gloucestershire, UK
Posts: 94
Default

I had some issue's with this - though with me the problem caused the player to crash rather than just do nothing. Make sure the file is a 44.100khz 16bit stereo PCM wave file, as that was the solution to my problem.

Also check its not muted :P
Reply With Quote

  #4  
Old 01-13-2010, 12:09 PM
Jan_DK's Avatar
Jan_DK Jan_DK is offline
Junior Member
 
Join Date: Mar 2009
Location: Denmark
Posts: 88
Default

Just tried to play two wave files in a row, and print the length of the wave in sec. and wait for the duration of the playing wave before closing, and starting the next one.

The code look like this
Code:
--setup
color_black = color.new(0,0,0);
color_white = color.new(255,255,255);
text.color(color_white);
text.size(16);
screen.clear();
screen.fillrect(0,0,400,240,color_black);
screen.update();

-- load and play music 1
sound1 = wav.load("mus1.wav");
Play_length = wav.time(sound1);
text.draw(10,10,"Play length sec. = "..Play_length/1000); screen.update();
wav.play(sound1);
os.sleep(Play_length/10);
wav.close(sound1);

-- load and play music 2
sound1 = wav.load("mus2.wav");
Play_length = wav.time(sound1);
text.draw(10,30,"Play length sec. = "..Play_length/1000); screen.update();
wav.play(sound1);
os.sleep(Play_length/10);
wav.close(sound1);

--end
text.draw(10,50,"ENDING"); screen.update();
os.sleep(500);
Something is not right if wav.time(sound1) return the length in ms,
and os.sleep() takes ms, then why do I have to divide with 10 to pause for the right length hmm ?

Edit: It got to be the os.sleep() function that takes units of 10ms.
os.sleep(500); sleep for 5 sec. not 0.5sec.

Edit2: looks like os.sleep() takes units of 10ms. and os.wait() take ms.

Jan_DK

Last edited by Jan_DK; 01-13-2010 at 12:25 PM.
Reply With Quote

  #5  
Old 01-13-2010, 12:30 PM
Jan_DK's Avatar
Jan_DK Jan_DK is offline
Junior Member
 
Join Date: Mar 2009
Location: Denmark
Posts: 88
Default

The same code using os.wait() and no dividing by 10, is also working.


Code:
--setup
color_black = color.new(0,0,0);
color_white = color.new(255,255,255);
text.color(color_white);
text.size(16);
screen.clear();
screen.fillrect(0,0,400,240,color_black);
screen.update();

-- load and play music 1
sound1 = wav.load("mus1.wav");
Play_length = wav.time(sound1);
text.draw(10,10,"Play length sec. = "..Play_length/1000); screen.update();
wav.play(sound1);
os.wait(Play_length);
wav.close(sound1);

-- load and play music 2
sound1 = wav.load("mus2.wav");
Play_length = wav.time(sound1);
text.draw(10,30,"Play length sec. = "..Play_length/1000); screen.update();
wav.play(sound1);
os.wait(Play_length);
wav.close(sound1);

--end
text.draw(10,50,"ENDING"); screen.update();
os.sleep(500);
Jan_DK
Reply With Quote

  #6  
Old 01-13-2010, 12:44 PM
Brett_val's Avatar
Brett_val Brett_val is offline
Senior Member
 
Join Date: Jan 2010
Location: The Netherlands
Posts: 636
Default

I tried different wave files of 16 and 26 MB. According to the log file from eac (which I used to rip cds) the output format is 44.100 Hz; 16 Bit; Stereo. I guess I'm solid there...

The player does not freeze of crash, it just stays in the application screen, and yeah the speaker is not muted .

I tried it with a file I copyd over from the recordings folder (IMA ADPCM 16000Hz mono 64Kbps, size=109KB) but that has the same result..

I was thinking I did not point it to the file correctly, but I get "Error occurred!" when I point it to a wave file that doesn't exist.
So I guess it sees the files, but can't do anything with it..?

It seems you had more luck with your files, although I couldn't find one that's 8MB, I'll try chopping the big ones when I find that nero wave editor program I once had..
My previous Zen Vision (not M or W) played these waves from cds out of the box, and I suppose that player didn't have 64MB ram either. (but it may have loaded parts of the file at a time). I don't get why this player doesn't support it anymore.

EDIT: I just saw your update, I copyd your code and it works to an extent that it shows the playlength of the first file, and after a while the play length of the second file appears in the screen, and it exits the app after a while again.
Which is great this way I could make "playlists" for wave files,

But.. I still hear nothing.. could it be the wave file? I ripped them all with EAC.

Last edited by Brett_val; 01-13-2010 at 12:55 PM.
Reply With Quote

  #7  
Old 01-13-2010, 01:00 PM
Jan_DK's Avatar
Jan_DK Jan_DK is offline
Junior Member
 
Join Date: Mar 2009
Location: Denmark
Posts: 88
Default

Here is a 1.6MB wave file that works
http://www.exras.netne.net/mus1.wav

It's be course of the Creative Lua environment and not the 32MB,
that we can't play 200MB songs

No sequential loading and buffering to my knowledge in Creative Lua.

Jan_DK
Reply With Quote

  #8  
Old 01-13-2010, 01:17 PM
Jan_DK's Avatar
Jan_DK Jan_DK is offline
Junior Member
 
Join Date: Mar 2009
Location: Denmark
Posts: 88
Default

Quote:
Originally Posted by Brett_val View Post

EDIT: I just saw your update, I copyd your code and it works to an extent that it shows the playlength of the first file, and after a while the play length of the second file appears in the screen, and it exits the app after a while again.
Which is great this way I could make "playlists" for wave files,

But.. I still hear nothing.. could it be the wave file? I ripped them all with EAC.
It sound's strange that it apparently load and display the file but not play it
hmm, I see if I can replicate that with the 35mb "unplayable" file.

Jan_DK
Reply With Quote

  #9  
Old 01-13-2010, 01:28 PM
Jan_DK's Avatar
Jan_DK Jan_DK is offline
Junior Member
 
Join Date: Mar 2009
Location: Denmark
Posts: 88
Default

Yes, I get the same results it display the length but no sound.

1. tried with a 38MB - Not working
2. tried with a 17MB - Not working
3. tried with a 12MB - Working !

Now I'll bet the X-Fi2 has 16MB RAM

Jan_DK

Last edited by Jan_DK; 01-13-2010 at 05:57 PM.
Reply With Quote

  #10  
Old 01-13-2010, 01:37 PM
Marvin the Martian's Avatar
Marvin the Martian Marvin the Martian is offline
Ultra Senior Member
 
Join Date: Oct 2008
Location: east central NY state
Posts: 10,602
Default

Why on earth would you want to play a WAV file on a DAP anyways?
__________________
iPod Touch 5G 32GB, Touch 4G 32GB, Clip Sport 8GB. Rockbox-> Clip Zip 4GB, iPod Nano 2G 4GB, iPod 5.5G 80GB
2012 Nexus 7 32GB, Asus MeMoPad 8 16+64GB, LG Optimus G Pro, Nokia Lumia 900 and Lumia 520
Reply With Quote

  #11  
Old 01-13-2010, 01:46 PM
ThievingSix ThievingSix is offline
Member
 
Join Date: Aug 2008
Posts: 218
Default

I did a benchmark with intervals of 5mb test wav files from 5 to 25. The biggest I got was the 10mb one to play. Hopefully creative remedies this with their new sound library in the sdk.

Edit: And..you beat me to it haha.
Reply With Quote

  #12  
Old 01-13-2010, 02:25 PM
Jan_DK's Avatar
Jan_DK Jan_DK is offline
Junior Member
 
Join Date: Mar 2009
Location: Denmark
Posts: 88
Default

I wanted to try a simple memory allocation prog.
Every 1K bytes it's printing the loop number.

But it's stops running at 32768(32K) with an error.

The question is what the 32K represents
32K * 4 bytes(Lua variable) = 128Kbytes ?

Code:
--setup
color_black = color.new(0,0,0);
color_white = color.new(255,255,255);
text.color(color_white);
text.size(16);
screen.clear();
screen.fillrect(0,0,400,240,color_black);
text.draw(10,10,"Memory test"); screen.update();

count=1;
BYTEss = {};


    for loop=1,256000 do
     BYTEss[loop]= 255 ;
     if (count==256) then
     screen.fillrect(0,0,400,240,color_black);
     text.draw(10,50,"loop = "..loop);
     screen.update();
     os.sleep(10);
     count=0;
     end;
     count=count+1;
    end;

text.draw(10,30,"END = "..loop);
screen.update();
Jan_DK

Last edited by Jan_DK; 01-18-2010 at 12:52 PM. Reason: add 32768
Reply With Quote

  #13  
Old 01-13-2010, 05:45 PM
ThievingSix ThievingSix is offline
Member
 
Join Date: Aug 2008
Posts: 218
Default

Jan_DK:
I just had a go to figure out our memory limitations. First it seems that arrays grow exponentially when you do it dynamically. Second it seems that we are limited by about 800kb of application stack space, as shown by this example:

Code:
--MemoryTest\MAIN.LUA
clBlack = color.new(0,0,0);
clWhite = color.new(255,255,255);

screen.clear();
screen.fillrect(0,0,400,240,clBlack);
text.color(clWhite);
text.size(25);
screen.update();
collectgarbage("stop");

MemoryTest = "";
LUAMemory = 0;
Count = 0;

while true do
  for I = 1, 10 do
    MemoryTest = string.char(math.random(1,255),math.random(1,255),math.random(1,255));
  end;
  Count = Count + 1;
  if ((Count % 5) == 0) then
    screen.fillrect(0,0,400,25,clBlack);
    LUAMemory = collectgarbage("count");
    text.draw(0,0,LUAMemory .. " kb");
    screen.update();
  end;
  if (control.read() == 1) and (control.isButton() == 1) and (button.home() == 1) and (button.hold() == 1) then
    screen.fillrect(0,0,400,25,clBlack);
    text.draw(0,0,"Please wait. . .");
    screen.update();
    collectgarbage("restart");
    collectgarbage("collect");
    break;
  end;
  os.wait(10);
end;
The application freezes at around 800kb.
Reply With Quote

  #14  
Old 01-15-2010, 10:46 AM
Brett_val's Avatar
Brett_val Brett_val is offline
Senior Member
 
Join Date: Jan 2010
Location: The Netherlands
Posts: 636
Default

Quote:
Originally Posted by Marvin the Martian View Post
Why on earth would you want to play a WAV file on a DAP anyways?
Because only a WAV contains all the information about the sounds. I want the sound in my ear to be as wide and detailed as it is when I play the cd at home, and even use the player as a substitute for the cds. If you want to get the best possible sound quality out of a device then it's a little weird to start out with compressed music files..
That's like buying a high definition tv and placing it behind a window.
The X-Fi would be the windowcleaner in this analogy

Quote:
Originally Posted by Jan_DK View Post
Yes, I get the same results it display the length but no sound.

1. tried with a 38MB - Not working
2. tried with a 17MB - Not working
3. tried with a 12MB - Working !

Now I'll bet the X-Fi2 has 16MB RAM

Jan_DK
Thank you for the file! It did work with your wave. I wanted to try out some different sizes, but I see you guys already did.

So, the only option would be to cut all my waves in pieces of 10MB. I've seen programs that may be able to do this. I might try it out to see if they play seemlessly.

Do any of you have a clue why this device is apparently able to play 44100Hz 16 bit stereo but the support for it in the library is left out? (older Zens still did have it..)
Reply With Quote

  #15  
Old 01-15-2010, 11:27 AM
Marvin the Martian's Avatar
Marvin the Martian Marvin the Martian is offline
Ultra Senior Member
 
Join Date: Oct 2008
Location: east central NY state
Posts: 10,602
Default

Quote:
Originally Posted by Brett_val View Post
Because only a WAV contains all the information about the sounds. I want the sound in my ear to be as wide and detailed as it is when I play the cd at home, and even use the player as a substitute for the cds. If you want to get the best possible sound quality out of a device then it's a little weird to start out with compressed music files..
That's like buying a high definition tv and placing it behind a window.
The X-Fi would be the windowcleaner in this analogy
You can accomplish the same thing with FLAC files then....they contain all the information, and save a fair bit of space.
__________________
iPod Touch 5G 32GB, Touch 4G 32GB, Clip Sport 8GB. Rockbox-> Clip Zip 4GB, iPod Nano 2G 4GB, iPod 5.5G 80GB
2012 Nexus 7 32GB, Asus MeMoPad 8 16+64GB, LG Optimus G Pro, Nokia Lumia 900 and Lumia 520
Reply With Quote

  #16  
Old 01-15-2010, 11:36 AM
Dreamnine Dreamnine is offline
Banned
 
Join Date: Dec 2008
Location: Scotland, EU
Posts: 3,225
Default

Why would you want to listen to FLAC on A DAP, though?
Reply With Quote

  #17  
Old 01-15-2010, 12:55 PM
Brett_val's Avatar
Brett_val Brett_val is offline
Senior Member
 
Join Date: Jan 2010
Location: The Netherlands
Posts: 636
Default

Quote:
Originally Posted by Marvin the Martian View Post
You can accomplish the same thing with FLAC files then....they contain all the information, and save a fair bit of space.
FLAC is also compressed. A little, but still. From what I've read about it, it seems to be a very good compression method, but it still takes away the "warmth" of a track.

Quote:
Originally Posted by Dreamnine View Post
Why would you want to listen to FLAC on A DAP, though?
Why would you want to tie your shoelaces
Reply With Quote

  #18  
Old 01-15-2010, 01:06 PM
Marvin the Martian's Avatar
Marvin the Martian Marvin the Martian is offline
Ultra Senior Member
 
Join Date: Oct 2008
Location: east central NY state
Posts: 10,602
Default

Quote:
Originally Posted by Brett_val View Post
Because only a WAV contains all the information about the sounds. I want the sound in my ear to be as wide and detailed as it is when I play the cd at home, and even use the player as a substitute for the cds. If you want to get the best possible sound quality out of a device then it's a little weird to start out with compressed music files..
That's like buying a high definition tv and placing it behind a window.
The X-Fi would be the windowcleaner in this analogy
Quote:
Originally Posted by Marvin the Martian View Post
You can accomplish the same thing with FLAC files then....they contain all the information, and save a fair bit of space.
Quote:
Originally Posted by Brett_val View Post
FLAC is also compressed. A little, but still. From what I've read about it, it seems to be a very good compression method, but it still takes away the "warmth" of a track.
Be prepared for a post by Enigmatic.
__________________
iPod Touch 5G 32GB, Touch 4G 32GB, Clip Sport 8GB. Rockbox-> Clip Zip 4GB, iPod Nano 2G 4GB, iPod 5.5G 80GB
2012 Nexus 7 32GB, Asus MeMoPad 8 16+64GB, LG Optimus G Pro, Nokia Lumia 900 and Lumia 520
Reply With Quote

  #19  
Old 01-15-2010, 01:07 PM
ThievingSix ThievingSix is offline
Member
 
Join Date: Aug 2008
Posts: 218
Default

Quote:
Originally Posted by Brett_val View Post
FLAC is also compressed. A little, but still. From what I've read about it, it seems to be a very good compression method, but it still takes away the "warmth" of a track.
Huh? Flac is lossless. Free Lossless Audio Codec. Flac. Meaning it doesn't take away anything because exactly what you put in before you compress is what you are going to get during playback.
Reply With Quote

  #20  
Old 01-15-2010, 02:50 PM
Brett_val's Avatar
Brett_val Brett_val is offline
Senior Member
 
Join Date: Jan 2010
Location: The Netherlands
Posts: 636
Default

WMA Lossless is also called lossless, which it is not.

I said that it's a little weird to start out with compressed music if you're looking for quality, because no matter how much equalizers and hi end amps you put behind it, it will stay lossy and some parts may even sound terrible after amplification.

FLAC on the other hand seems to output music bit-per-bit identical to the original. But from what I've read it still misses some depth or warmth, and while I can hardly understand that because FLAC should be exactly the same, I decided to not take any chances and save everything in the original uncompressed wave output, which was also very handy because it's widely supported. I used to play those waves with my Zen, but as I've said, the support for wave has changed with the X-Fi 2 and I'm looking for a way to play those files.

Maybe FLAC took the place of wave in the new Zen. I did encode some waves to FLAC and it sounds great but I'm not sure if it's the same as I had before.. or maybe I just have to get used to the sound of my new player.
Marvin seems to have quite an expectation about Enigmatic. If Enigmatic can enlighten me about the doubt some people have about FLAC I'd be happy to read it.
Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 01:45 PM.