Android Audio

Android, why do I come back to this platform? It could be so awesome, but it’s full of fail. Lately I’ve been trying to get a X/Y  pad thing going on, Like a kaossilator thing.
While it works in principal, it does have some latency. about 100ms latency. That’s not musicians grade at all! I have however managed to apply dirty trix and evil hacks.

Expect at least 3 touchscreen-driven musical instruments on the Android from me and Staffan, and since the Android market is a bad place to be if you want to charge for your apps, we’ll try out Advertisement this time around.

I’m a better driver than most.

In Sweden, you are not allowed to be good at anything, it’s called Jantelagen and it comes sneaks up upon you even though you know it exists. One thing is that there are some “statistics” from a “survey” that everybody knows of (though I have not been able to find it) that say that “90% of the Swedish population think that they are better driver then most”. This “fact” is often followed by a chuckle and and the appendix “that cant be true, because 90% is more then 10%, and that’s not half”. This kills anyone dead that think they are a good driver.

The important thing here I think is that Swedes as a people totally forgets to analyze why the alledged 90% think they are good drivers. (trust me, we are not a land of champion f-1 drivers). Is it because they think that everybody else does lots of mistakes and drive badly (perhaps because of stupidity)? Or is it because you think you’re special (as the jante law tells you that you cannot be).

I know I make mistakes while driving, I know I forget rules from time to time, especially seldom used ones. I know I don’t remember all the roadsigns. What I also know is that I do know these things and when I made a mistake or found something that I’m unsure of, I look it up. I try to improve, that’s makes me a better driver then most other drivers I think. I avoid putting anyone in dangerous situations, or situations that I cant control. When it’s bad weather (like loads of snow and stuff) and I don’t need to use the car, guess what, I don’t!

What I’m saying is that I try to improve, and I use common sense, and I think that makes me a better driver.

Avatar

So I watched that Avatar movie last night and I spent way to much time thinking about how one of the people would taste like. I think they would taste best BBQ’ed. jumm jumm.

On a side-note I’m turning 33 today, Hooray for me!

The bedazzler porting spree

After watching lady Ada’s information about the bedazzler I went on a porting spree. But first a little something about “the bedazzler” in case you don’t care to read up on the link. The US Dept. of Homeland Security has spent 1 million dollars on creating a “sea-sick flashlight” that they intend to use as a riot control device. It’s non-lethal and it’s better for the environment then teargas.

Lady Ada’s device is an open source clone of the Dazzler dubbed “the Bedazzler” funny I though, but spending 250 dollars getting your friends and family sick was not really going to happen. But then one night I had the idea to port the bedazzler to an Android device. That was pretty easy since processing.org released a test-beta that could make Android applications, otherwise I’d spend that evening installing Eclipse and swearing. Anyways I made it, and a video of it is is here:

Anyways, It worked in the Android emulator, got me sick so I had to go to bed 🙂 funny, but It does not work on the device, to low frame rate I think. Here’s the source if you are wanting to test it. Please note that you’re probably going to get sick. Here’s a direct link to the applet. Don’t send your friends here!

Then I thought, I want a mobile version, and I do have a blinkM that I have not used for anything yet. the blinkM is a RGB led with a microprocessor. First of I did what every sane person would do. I hooked up the blinkM to an Arduino and ported the code once more to suit the current platform. Here’s the source for that. Somewhat efficient. Here’s a video of it:

I also wanted to create a standalone version, since you can upload code to the blinkM and run it without an Arduino. There I ran into some trouble. The time slots on the blinkM is a divided by 33 milliseconds, so the lowest I can go is 33ms between blinks, and then 66 and then 99. I made the port anyways (that was so simple I didn’t even save the source), but It has no effect on me at all, here’s a video:

Now I’m going to see if I can make a device that does the opposite.

Crush it!, a review

Crush it! is a book written by Gary Vaynerchuk, it’s all about how you should change your life and get rich with the use of social media. you know, like writing a blog, being on Facebook/twitter/myspace etc etc (having fanpages and the such). Some of the thing’s he say are direct opposite of 4 hour workweek (witch i reviewed before). Gary thinks that if you only do a lot of what your passion is, you’ll eventually get rich. Building content is king in his book. It’s a fairly quick read, the book, and it’s full of very macho language “DO IT, DO IT NOW” . I found that rather amusing. Anyways, It got me started making the i_am_larsulrich twitterbot so that was a good thing. The second good thing about it was me getting to know about services that takes your video and uploads them to every videosite there is. Hooray!

It’s an entertaining read, but it does not make you think on how you are living your life, no introspection for me there!

http://crushitbook.com/

A little rant about Swedish toll

Toll in Sweden are taxes on foreign stuff imported. I have no big beef with paying taxes. Taxes are how we keep our society going. Sure the elected officials could be more efficient in smarter way’s but that is not really the issue here, most of the money go to the places where they should be. So when I buy something from America or any other non EU country the Swedish Toll office takes the value of that thing and adds tax. Usually 25% of what the thing costs. That’s all fine and dandy, but then the post office adds a seemingly random amount that they label “speditional fees”.

Let’s take my last international purchase for example, it was 75 USD (freight included)
75 USD is 543.05 SEK
Value was declared on the package and I got a letter home telling me I had to pay to pick my package up. Strange thing that I have to go somewhere to pick something up that the freight is already payed for. The amount I have to pay is 201 SEK. About 37% of the value. tax in sweden is usually at 25%. So when I was eager to see why the amount differd so much.
The value declared on the parcel was 75 USD, I don’t really think you have to pay toll for the freight, but the toll-officials don’t know that that was included, right!
At the specification 138 SEK is toll and taxes. witch is 25% no problem there. Then the postal office takes 63 SEK because toll was payed, in the spedition-fee. That’s the extra 13% add on the price. So I guess what really happens here is that I get to pay them for making me pay the Toll. I shouldn’t have to pay for the parcel being sent around. That was already payed for. I’ve searched for information on what I really pay for on the web, and asked postal workers. I still have no idea where those extra money really goes.

Dronesizer pt 2

So I’m like working on my dronesizer, and I’m like not getting so far ahead as I like to, but like, I wanna show it anyways. So I’ve made a little movie:

Basically it is a resistor ladder digital to analog converter, check out the R2R DAC if you want to build one. I added LED’s as well. I’ve also added 6 potentiometers. Just do this 6 times 🙂

It’s as easy as that. Now I need to add more sound options and tighten the void loop() function because it’s dead slow right now.

//audio out variables
float TEMP= 0.0;

#define SINC_LENGTH 32 

float sinC[3][SINC_LENGTH] = {
  {//sinus
    0.59754515,0.69134176,0.7777851,0.8535534,0.9157348,0.96193975,0.9903926,1.0,0.9903927,0.9619398,0.9157348,0.8535534,0.77778506,0.69134164,0.597545,0.49999985,0.40245464,0.30865806,0.22221464,0.14644638,0.08426499,0.03806007,0.009607285,0.0,0.009607464,0.038060457,0.08426553,0.14644706,0.22221544,0.30865896,0.4024556,0.5000008,  }
  ,
  {//saw
    1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,  }
  ,
  {//tri
    0.03125,0.0625,0.09375,0.125,0.15625,0.1875,0.21875,0.25,0.28125,0.3125,0.34375,0.375,0.40625,0.4375,0.46875,0.5,0.53125,0.5625,0.59375,0.625,0.65625,0.6875,0.71875,0.75,0.78125,0.8125,0.84375,0.875,0.90625,0.9375,0.96875,1.0,  }
};

int incomingByte = 0;	// for incoming serial datar

int pin0val =0;

enum waveFormType {
  SIN, SQUARE,TRI,  };

/*
float vol1=1.0;
 float vol2=1.0;
 float vol3=1.0;
 float vol4=1.0;*/

float globalHz1 =0.001;
float oscCount1=0;

float globalHz2 =0.001;
float oscCount2=0;

float globalHz3 =0.001;
float oscCount3=0;

float LFOHz =0.001;
float lfoCount=0;

int type=0;

void setup()
{

  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
  Serial.begin(9600);

  randomSeed(analogRead(0));

  //Timer2 setup  This is the audio rate timer, fires an interrupt at 15625 Hz sampling rate
  TIMSK2 = 1<<<SINC_LENGTH)
    oscCount1=0;
  oscCount2+=globalHz2;
  if(oscCount2>SINC_LENGTH)
    oscCount2=0;
  oscCount3+=globalHz3;
  if(oscCount3>SINC_LENGTH)
    oscCount3=0;
  lfoCount+=LFOHz;
  if(LFOHz>SINC_LENGTH)
    LFOHz=0;

}

void calculateHz(float in,float detune1, float detune2)
{

  globalHz1 = ((440 * pow(2.0,(in-69.0)/12.0))/1562.50);
  globalHz2 = (440 * pow(2.0,(detune1-69.0)/12.0))/1562.50;
  globalHz3 = (440 * pow(2.0,(detune2-69.0)/12.0))/1562.50;

  /*
  Serial.print("  ");
   Serial.print(globalHz1*100000, DEC);
   Serial.print("  ");
   Serial.print(globalHz2*100000, DEC);
   Serial.print("  ");
   Serial.print(globalHz3*100000, DEC);
   */
}

void loop()
{

  LFOHz = (analogRead(3)/(SINC_LENGTH*10.0));
  type=analogRead(5)/51;// 20 modes
  float note = ((analogRead(0)/1024.0)*100.0);
  calculateHz(note,note-(((analogRead(1)/1024.0)*2.0)-1.0),note-(((analogRead(2)/1024.0)*2.0)-1.0));

  /*
  Serial.println("vol ");

   Serial.print(vol,DEC);

   Serial.println(" LFOHz");
   Serial.print(LFOHz,DEC);

   Serial.print("analog 1: ");
   Serial.print( analogRead(1),DEC);

   Serial.print("___ analog 2: ");
   Serial.print( analogRead(2),DEC);

   Serial.print(" type ");
   Serial.print(type);

   Serial.print(" Note ");
   Serial.print((int)(note) );
   Serial.println(" ");

   */
}