Play RAW from Serial Flash

Status
Not open for further replies.
Hi Frank

Just implementing flash playback but can't find spi_flash.cpp / .h anywhere!!!

searched your code repository, searched Audio code repository, no joy. I have the latest github repository syncing to my arduino folder, has this file been renamed?
I've searched the audio thread and there are numerous mentions of this mysterious beast.

conclusion: I am doing something stupid. again.

Can you throw me a clue please? :)
 
Also, wav2raw.exe doesn't run on 64bit windows 7

wav2rawerror.jpg
 
Hi Frank

Just implementing flash playback but can't find spi_flash.cpp / .h anywhere!!!

searched your code repository, searched Audio code repository, no joy. I have the latest github repository syncing to my arduino folder, has this file been renamed?
I've searched the audio thread and there are numerous mentions of this mysterious beast.

conclusion: I am doing something stupid. again.

Can you throw me a clue please? :)

Ehhm... there is no spi_flash needed... (?!?)
Ok, the flashing tool needs flash_spi.h (<-read! :) ), which is in the arduinio/libraries/audio folder

Your screenshot: Hmm.. funny, i use it on windows7 64 bit :-((
I look at this tomorrow.

Then, there seems to be a problem with AudioStartUsingSPI() and AudioStopUsingSPI ... if playing does not work for you, comment it out in the lib for the moment. Just found this issue some minutes ago.
Tomorrow is the 13th... is this a sign ?
 
Could you try both versions from the attachment,please ?

I'll try to run it at work, tomorrow, maybe i can find the issue.

Paul, do you have an idea ?
 

Attachments

  • wav2raw.zip
    17.3 KB · Views: 136
Ehhm... there is no spi_flash needed... (?!?)
Ok, the flashing tool needs flash_spi.h (<-read! :) ), which is in the arduinio/libraries/audio folder

no it isn't; I wrote it the wrong way round (sorry :) ) but it is not there in github, which is what I am synced to. Therefore not in my arduino folder.
https://github.com/PaulStoffregen/Audio

i even logged out of github in case it was due to my login., still no flash_spi or spi_flash files at all.

Your screenshot: Hmm.. funny, i use it on windows7 64 bit :-((
I look at this tomorrow.

just to prove it : wav2rawerrorpc.jpg


Then, there seems to be a problem with AudioStartUsingSPI() and AudioStopUsingSPI ... if playing does not work for you, comment it out in the lib for the moment. Just found this issue some minutes ago.
Tomorrow is the 13th... is this a sign ?

OK, noted, thanks
 
... maybe i use another teensyduino version.. i attached both..
 

Attachments

  • flash_spi.zip
    4.6 KB · Views: 160
Thank you, all my files are loading into flash and verified OK, and it handled a hidden file with more than 8.3 filename just fine as well :)

_delete_
 
Hmmmm....

I just replaced all my Audacity RAW files with the ones from wav2raw and now they are all screwed up. Length incorrect, lots of problems.

I checked the playRAW function from the Audio library and cannot see the format info being read by the library.

Code:
bool AudioPlaySdRaw::play(const char *filename)
{
	stop();
	AudioStartUsingSPI();
	__disable_irq();
	rawfile = SD.open(filename);
	__enable_irq();
	if (!rawfile) {
		//Serial.println("unable to open file");
		return false;
	}
	file_size = rawfile.size();
	file_offset = 0;
	//Serial.println("able to open file");
	playing = true;
	return true;
}

Code:
void AudioPlaySdRaw::update(void)
{
	unsigned int i, n;
	audio_block_t *block;

	// only update if we're playing
	if (!playing) return;

	// allocate the audio blocks to transmit
	block = allocate();
	if (block == NULL) return;

	if (rawfile.available()) {
		// we can read more data from the file...
		n = rawfile.read(block->data, AUDIO_BLOCK_SAMPLES*2);
		file_offset += n;
		for (i=n/2; i < AUDIO_BLOCK_SAMPLES; i++) {
			block->data[i] = 0;
		}
		transmit(block);
	} else {
		rawfile.close();
		AudioStopUsingSPI();
		playing = false;
	}
	release(block);
}

just posted that from github
solution - i'll go back to my old RAWs for now

One other thing i noticed is the noise on the Audio bus when writing to the flash chip. Small thing, doesn't bother me in the slightest really. But worth mentioning.
 
UPDATE, hold that thought, SDcard suddenly stopped working and reported zero files. trying a reformat.

Possibly because i did a Quickformat, not necessarily any problems yet.
 
Hmmmm....

I just replaced all my Audacity RAW files with the ones from wav2raw and now they are all screwed up. Length incorrect, lots of problems.

I checked the playRAW function from the Audio library and cannot see the format info being read by the library.

Code:
bool AudioPlaySdRaw::play(const char *filename)
{
	stop();
	AudioStartUsingSPI();
	__disable_irq();
	rawfile = SD.open(filename);
	__enable_irq();
	if (!rawfile) {
		//Serial.println("unable to open file");
		return false;
	}
	file_size = rawfile.size();
	file_offset = 0;
	//Serial.println("able to open file");
	playing = true;
	return true;
}

Code:
void AudioPlaySdRaw::update(void)
{
	unsigned int i, n;
	audio_block_t *block;

	// only update if we're playing
	if (!playing) return;

	// allocate the audio blocks to transmit
	block = allocate();
	if (block == NULL) return;

	if (rawfile.available()) {
		// we can read more data from the file...
		n = rawfile.read(block->data, AUDIO_BLOCK_SAMPLES*2);
		file_offset += n;
		for (i=n/2; i < AUDIO_BLOCK_SAMPLES; i++) {
			block->data[i] = 0;
		}
		transmit(block);
	} else {
		rawfile.close();
		AudioStopUsingSPI();
		playing = false;
	}
	release(block);
}

just posted that from github
solution - i'll go back to my old RAWs for now

One other thing i noticed is the noise on the Audio bus when writing to the flash chip. Small thing, doesn't bother me in the slightest really. But worth mentioning.

- Please look at the raw flash player... there is the header used.
- The sdplayer can't play ulaw and the other formats. therfore it does not need any information about the format...
- Then, there are not any writes to the sd-card. So it's unlikely that the card gets corrupted.
- The noise.. i don't know. There is no Audiooutput... the i2s connection is not used (?!)
 
Last edited:
You read my mind, we should not use .raw for files that have a header. Simple common sense, because that is not what they are.

We will get there! baby steps!

_________________

Now, I hate to bring problems people's way but i used wav2raw64 on my WAV files, all 44khz 16bit mono.

All the RAW files are half as big as they should be.

Here's a zip full of the the original WAVs, Audacity RAWs, and wav2raw RAWs, so you can have a look


https://dl.dropboxusercontent.com/u/6452764/FrankB.zip

I also tried converting my WAVs to stereo, and then running the tool, but to no avail, only 2.3MB of data where there should be 4.6

edit: wav2raw32 gives same result

Rgds

J
 
Try wav2raw -16

It's basically Pauls wav2sketch, with the same features and options. I simply modified the output. Instead of c-source the output are raw bytes.
Without -16 it produces ulaw "compressed" audio. This has half of the size...exactly.

Anyway, the player detects this and plays it correctly. The quality is not as perfect as 16bit, but sounds good. Maybe you want to give it a try ?

EDIT: Just tried one single file, P2.raw from the "FrankB wav2raw64" directory from your upload. Flashed it, and it's ok. Equal to your "Source WAV"....
 
Last edited:
I'm doing something stupid again...aren't I.

I blame work, taking all my attention off the important things in life.

=D
 
polyphony is looking pretty awesome.

6 samples are peaking at 58%, so polyphony has effectively doubled by using the flash =D

working great by the way, feels much snappier, and my ps/2 funny character problems seem to have evaporated
 
8 samples all at once with envelopes = 76%

9 samples = 88.7% peak

But more importantly than polyphony, it now _feels_ like a drum machine. I feel like i can bash away and it will respond - this was not the case previously. Thank you Frank! =D

big smiles here :)
 
Last edited:
Status
Not open for further replies.
Back
Top