fiduciary

Author Topic: TeensySaber Software Discussion  (Read 67200 times)

0 Members and 2 Guests are viewing this topic.

Offline KanyonKris

  • Padawan Learner
  • **
  • Posts: 72
  • Um...Hello?
SmoothSwing V2 problems with SD card
« Reply #225 on: February 01, 2018, 12:01:48 AM »
Had problems trying out SmoothSwing V2 tonight. I used thexter's new sounds (SmoothGrey and SmoothJedi). My first preset uses a SmoothSwing V1 polyphonic sound font and it always worked, although when I switched it to SmoothSwing V2 it got a little scratchy sounding. But thexter's fonts with SmoothSwing V2 were all garbled and it even caused the blade in and out to be slow, much weirdness. I tried reducing the WAV files from 44kHz to 22kHz, but no help. Finally I switched to the Teensy optimzed SD card code (#include sd_t3.h with USE_TEENSY3_OPTIMIZED_CODE uncommented) and everything worked great.

I'm guessing this means my microSD card is the problem. It's a Kingston 8 GB microSDHC Class 4 that has fairly good reviews on Amazon. Do I need higher than Class 4? I'll try a different card tomorrow.

BTW, if you use the Teensy optimized SD code, the sd_t3.h file comments are very clear that it is read only so you won't be able to use MTP disk.

Offline KanyonKris

  • Padawan Learner
  • **
  • Posts: 72
  • Um...Hello?
SmoothSwing V2
« Reply #226 on: February 01, 2018, 12:09:29 AM »
Note: put a copy of smoothsw.ini in each font directory. You can have different SmoothSwing settings for each font. I first tried putting just one smoothsw.ini in the root directory and that doesn't work.
« Last Edit: February 01, 2018, 08:29:53 AM by KanyonKris »

Offline profezzorn

  • Mining Colony Members
  • Master Force User
  • *
  • Posts: 901
  • May the source be with you.
    • Hubbe's Corner
Re: TeensySaber Software Discussion
« Reply #227 on: February 01, 2018, 12:45:52 AM »
SD card bandwidth can be .a problem, but different SD cards seems to have different problems. My sandisk cards seems to work pretty well, but if I try to turn on USE_TEENSY3_OPTIMIZED_CODE, it doesn't work, not sure why.
I'm not sure that the class is the problem, because teensy uses the the sd card with a single data line, while the class is measured using four data lines. It's possible that some sd cards are just slow when using a single data line.

Offline profezzorn

  • Mining Colony Members
  • Master Force User
  • *
  • Posts: 901
  • May the source be with you.
    • Hubbe's Corner
Re: TeensySaber Software Discussion
« Reply #228 on: February 01, 2018, 12:47:53 AM »
PS, I think I'm going to add a command for benchmarking the SD card in the next version.

Offline profezzorn

  • Mining Colony Members
  • Master Force User
  • *
  • Posts: 901
  • May the source be with you.
    • Hubbe's Corner
Re: TeensySaber Software Discussion
« Reply #229 on: February 01, 2018, 11:01:22 AM »
Hmm, it occurs to me that the code that re-starts a looping sound is less than optimial, especially if two files are doing it at the same time.
I'm going to see if I can improve that.

Offline KanyonKris

  • Padawan Learner
  • **
  • Posts: 72
  • Um...Hello?
Re: TeensySaber Software Discussion
« Reply #230 on: February 01, 2018, 12:18:59 PM »
Hmm, it occurs to me that the code that re-starts a looping sound is less than optimial, especially if two files are doing it at the same time.
I'm going to see if I can improve that.
I am happy to test code changes with my seemingly finicky Kingston microSD card.

BTW, I'm curious about this: When I #include sd_t3.h and uncomment USE_TEENSY3_OPTIMIZED_CODE, it compiles and works fine. But when I #include sd_t3.h and comment out USE_TEENSY3_OPTIMIZED_CODE I got a long list of compiler errors all similar to this:
Code: [Select]
lightsaber:2113: error: 'File' does not name a type
   typedef File FILE;
Maybe not worth bothering with but the comments in sd_t3.h seem to indicate that even without USE_TEENSY3_OPTIMIZED_CODE there may be some performance improvements and it would be nice to be able to write to the microSD card. This is what the sd_t3.h says:
Code: [Select]
// This Teensy 3.x optimized version is a work-in-progress.
//
// Uncomment this line to use the Teensy version, which completely replaces
// all of the normal Arduino SD library code.  The optimized version is
// currently read-only.  It CAN NOT WRITE ANYTHING TO YOUR SD CARD.  However,
// it is *much* faster for reading more than 1 file at a time, especially for
// the Teensy Audio Library to play and mix multiple sound files.
//
//#define USE_TEENSY3_OPTIMIZED_CODE

/* Why reinvent the SD library wheel...
 *   1: Allow reading files from within interrupts
 *   2: Cache more than one sector for improved performance
 *   3: General optimization for 32 bit ARM on Teensy 3.x & Teensy-LC
 *   4: Permissive MIT license
 */
Or am I misreading/misunderstanding this?

Offline profezzorn

  • Mining Colony Members
  • Master Force User
  • *
  • Posts: 901
  • May the source be with you.
    • Hubbe's Corner
Re: TeensySaber Software Discussion
« Reply #231 on: February 01, 2018, 12:27:02 PM »
There is no need to include SD_t3.h directly, as it is included from SD.h.
If USE_TEENSY3_OPTIMIZED_CODE is defined, SD_t3.h defines __SD_H__ which prevents the rest of SD.h from actually doing anything.
Without USE_TEENSY3_OPTIMIZED_CODE SD_t3.h does exactly nothing.

Offline KanyonKris

  • Padawan Learner
  • **
  • Posts: 72
  • Um...Hello?
Re: TeensySaber Software Discussion
« Reply #232 on: February 01, 2018, 12:56:19 PM »
There is no need to include SD_t3.h directly, as it is included from SD.h.
If USE_TEENSY3_OPTIMIZED_CODE is defined, SD_t3.h defines __SD_H__ which prevents the rest of SD.h from actually doing anything.
Without USE_TEENSY3_OPTIMIZED_CODE SD_t3.h does exactly nothing.
Ah, I see. Thank you for the explanation.

Thanks again for sharing all your saber work. I don't understand all your code, but I understand enough to be impressed by how awesome it is. The event handling, the preset template system, audio, handling a variety of hardware - all so good.

Offline profezzorn

  • Mining Colony Members
  • Master Force User
  • *
  • Posts: 901
  • May the source be with you.
    • Hubbe's Corner
Re: TeensySaber Software Discussion
« Reply #233 on: February 01, 2018, 10:57:28 PM »
This is untested, but I hacked up a minor optimization for audio loops, plus a command called "sdtest" which benchmarks the sd card.
Here is what I get:
Code: [Select]
Playing caliban/hum01.wav
Each dot is 64kB
................
................
................
................
................
................
................
................
Done
SD card speed:
874.82 kb/s = 9.92 simultaneous audio streams.

You can download the untested code here: http://fredrik.hubbe.net/lightsaber/lightsaber-1.194.zip


Offline KanyonKris

  • Padawan Learner
  • **
  • Posts: 72
  • Um...Hello?
Re: TeensySaber Software Discussion
« Reply #234 on: February 02, 2018, 03:16:03 PM »
Installed the 1.194 firmware without USE_TEENSY3_OPTIMIZED_CODE. SmoothSwing V2 works good, no garbled audio. Thanks, profezzorn!

Ran sdtest:

Code: [Select]
Playing f-stndrd/hum02.wav
Each dot is 64kB
................
................
................
................
................
................
................
................
Done
SD card speed:
1018.65 kb/s = 11.55 simultaneous audio streams.

Looks like my Kingston card should be OK. If it matters, hum02.wav is 22kHz, 16 bit, mono.

UPDATE: This is the Kingston microSD card I have - Amazon.com: Kingston 8 GB microSDHC Class 4 Flash Memory Card SDC4/8GBET:
« Last Edit: February 03, 2018, 01:49:01 PM by KanyonKris »

Offline profezzorn

  • Mining Colony Members
  • Master Force User
  • *
  • Posts: 901
  • May the source be with you.
    • Hubbe's Corner
Re: TeensySaber Software Discussion
« Reply #235 on: February 02, 2018, 03:23:31 PM »
Installed the 1.194 firmware without USE_TEENSY3_OPTIMIZED_CODE. SmmothSwing V2 works good, no garbled audio. Thanks, profezzorn!

Ran sdtest:

Code: [Select]
Playing f-stndrd/hum02.wav
Each dot is 64kB
................
................
................
................
................
................
................
................
Done
SD card speed:
1018.65 kb/s = 11.55 simultaneous audio streams.

Looks like my Kingston card should be OK. If it matters, hum02.wav is 22kHz, 16 bit, mono.

It doesn't matter. It just reads data from the file, calculates the kb/s and divides by 88.2 to get number of streams.
(Which assumes 44.1kHz, it would be twice as many 22kHz streams.)

Offline KanyonKris

  • Padawan Learner
  • **
  • Posts: 72
  • Um...Hello?
Re: TeensySaber Software Discussion
« Reply #236 on: February 02, 2018, 04:34:15 PM »
When I use the InOutSparkTip preset I see the SPARK_COLOR when the blade extends, but not when it retracts. For example, this preset from common_presets.h:

{ "graflex7", "tracks/cantina.wav", StylePtr<InOutSparkTip<EasyBlade<BLUE, WHITE>, 300, 800> >(), "blue" },

Also, what is the range of values for GRADE and what does GRADE do in BrownNoiseFlicker?
« Last Edit: February 02, 2018, 04:45:36 PM by KanyonKris »

Offline profezzorn

  • Mining Colony Members
  • Master Force User
  • *
  • Posts: 901
  • May the source be with you.
    • Hubbe's Corner
Re: TeensySaber Software Discussion
« Reply #237 on: February 02, 2018, 05:08:51 PM »
When I use the InOutSparkTip preset I see the SPARK_COLOR when the blade extends, but not when it retracts. For example, this preset from common_presets.h:

{ "graflex7", "tracks/cantina.wav", StylePtr<InOutSparkTip<EasyBlade<BLUE, WHITE>, 300, 800> >(), "blue" },

Also, what is the range of values for GRADE and what does GRADE do in BrownNoiseFlicker?

I did the spark tip only on extension since I thought that made more sense.
I suppose we could add an option for doing it on retraction too.

The brown noise mix is 0-255, and for each pixel the mix changes by picking a random value between mix - grade and mix + grade. The brown mix does not carry state over time though, which makes it not very useful. I need to make some random thingies with some control over the frequency of the randomness as well...

Offline KanyonKris

  • Padawan Learner
  • **
  • Posts: 72
  • Um...Hello?
Re: TeensySaber Software Discussion
« Reply #238 on: February 02, 2018, 05:39:00 PM »
I did the spark tip only on extension since I thought that made more sense.
I suppose we could add an option for doing it on retraction too.
Spark tip only on extension does make sense. Spark tip retraction might look fun, but this is a small matter.

I came up with a preset I quite like. It's basically EasyBlade but I added AudioFlicker between full blue and a little darker blue (Rgb<0, 0, 180>) so the blade flickers a bit, makes it a bit more dynamic.

  { "smthjedi", "tracks/cantina.wav", StylePtr<InOutSparkTip<SimpleClash<Lockup<Blast<AudioFlicker<BLUE, Rgb<0,0,200> >, WHITE>, AudioFlicker<BLUE, WHITE> >, WHITE>, 300, 800> >(), "blueflicker" },

UPDATE: Actually this can be written more simply using EasyBlade:

  { "smthjedi", "tracks/cantina.wav", StylePtr<InOutSparkTip<EasyBlade<AudioFlicker<BLUE, Rgb<0,0,200> >, WHITE>, 300, 800> >(), "blueflicker" },
« Last Edit: February 03, 2018, 02:30:37 PM by KanyonKris »

Offline profezzorn

  • Mining Colony Members
  • Master Force User
  • *
  • Posts: 901
  • May the source be with you.
    • Hubbe's Corner
Re: TeensySaber Software Discussion
« Reply #239 on: February 02, 2018, 06:51:45 PM »
I did the spark tip only on extension since I thought that made more sense.
I suppose we could add an option for doing it on retraction too.
Spark tip only on extension does make sense. Spark tip retraction might look fun, but this is a small matter.

I came up with a preset I quite like. It's basically EasyBlade but I added AudioFlicker between full blue and a little darker blue (Rgb<0, 0, 180>) so the blade flickers a bit, makes it a bit more dynamic.

{ "smthjedi", "tracks/cantina.wav", StylePtr<InOutSparkTip<SimpleClash<Lockup<Blast<AudioFlicker<BLUE, Rgb<0,0,180> >, WHITE>, AudioFlicker<BLUE, WHITE> >, WHITE>, 300, 800> >(), "blueflicker" },

Nice, sharing blade styles is a nice and easy way for people to get into tweaking their configurations, more of that!

 

retrousse