| 
															 | 
															 | 
															 | 
															 | 
															 | 
														
														
													
														
															 | 
															 | 
															 */ | 
															 | 
															 | 
															 */ | 
														
														
													
														
															 | 
															 | 
															
  | 
															 | 
															 | 
															
  | 
														
														
													
														
															 | 
															 | 
															#include "play_sd_wav.h" | 
															 | 
															 | 
															#include "play_sd_wav.h" | 
														
														
													
														
															 | 
															 | 
															 | 
															 | 
															 | 
															#include "spi_interrupt.h" | 
														
														
													
														
															 | 
															 | 
															
  | 
															 | 
															 | 
															
  | 
														
														
													
														
															 | 
															 | 
															#define STATE_DIRECT_8BIT_MONO		0  // playing mono at native sample rate | 
															 | 
															 | 
															#define STATE_DIRECT_8BIT_MONO		0  // playing mono at native sample rate | 
														
														
													
														
															 | 
															 | 
															#define STATE_DIRECT_8BIT_STEREO	1  // playing stereo at native sample rate | 
															 | 
															 | 
															#define STATE_DIRECT_8BIT_STEREO	1  // playing stereo at native sample rate | 
														
														
													
												
													
														
															 | 
															 | 
															 | 
															 | 
															 | 
															 | 
														
														
													
														
															 | 
															 | 
															bool AudioPlaySdWav::play(const char *filename) | 
															 | 
															 | 
															bool AudioPlaySdWav::play(const char *filename) | 
														
														
													
														
															 | 
															 | 
															{ | 
															 | 
															 | 
															{ | 
														
														
													
														
															 | 
															 | 
																stop(); | 
															 | 
															 | 
																stop(); | 
														
														
													
														
															 | 
															 | 
															 | 
															 | 
															 | 
																AudioStartUsingSPI(); | 
														
														
													
														
															 | 
															 | 
																__disable_irq(); | 
															 | 
															 | 
																__disable_irq(); | 
														
														
													
														
															 | 
															 | 
																wavfile = SD.open(filename); | 
															 | 
															 | 
																wavfile = SD.open(filename); | 
														
														
													
														
															 | 
															 | 
																__enable_irq(); | 
															 | 
															 | 
																__enable_irq(); | 
														
														
													
												
													
														
															 | 
															 | 
															 | 
															 | 
															 | 
															 | 
														
														
													
														
															 | 
															 | 
																	if (b1) release(b1); | 
															 | 
															 | 
																	if (b1) release(b1); | 
														
														
													
														
															 | 
															 | 
																	if (b2) release(b2); | 
															 | 
															 | 
																	if (b2) release(b2); | 
														
														
													
														
															 | 
															 | 
																	wavfile.close(); | 
															 | 
															 | 
																	wavfile.close(); | 
														
														
													
														
															 | 
															 | 
															 | 
															 | 
															 | 
																	AudioStopUsingSPI(); | 
														
														
													
														
															 | 
															 | 
																} else { | 
															 | 
															 | 
																} else { | 
														
														
													
														
															 | 
															 | 
																	__enable_irq(); | 
															 | 
															 | 
																	__enable_irq(); | 
														
														
													
														
															 | 
															 | 
																} | 
															 | 
															 | 
																} | 
														
														
													
												
													
														
															 | 
															 | 
															 | 
															 | 
															 | 
															 | 
														
														
													
														
															 | 
															 | 
																} | 
															 | 
															 | 
																} | 
														
														
													
														
															 | 
															 | 
															end:	// end of file reached or other reason to stop | 
															 | 
															 | 
															end:	// end of file reached or other reason to stop | 
														
														
													
														
															 | 
															 | 
																wavfile.close(); | 
															 | 
															 | 
																wavfile.close(); | 
														
														
													
														
															 | 
															 | 
															 | 
															 | 
															 | 
																AudioStopUsingSPI(); | 
														
														
													
														
															 | 
															 | 
																state_play = STATE_STOP; | 
															 | 
															 | 
																state_play = STATE_STOP; | 
														
														
													
														
															 | 
															 | 
																state = STATE_STOP; | 
															 | 
															 | 
																state = STATE_STOP; | 
														
														
													
														
															 | 
															 | 
															cleanup: | 
															 | 
															 | 
															cleanup: |