Creating “Analogue” Static with Extremely Expensive Software: a Comprehensive Guide

Odds are if you have a piece of software such as MATLAB, you did not compensate MathWorks® for their product unless you are currently engaged in a mutually beneficial relationship with a large organization, you are insane, or you are filthy rich.

With that in mind, the topic of the day is how to make the “most” of your incredibly expensive software that you did not pay for.

Do you remember when televisions weren’t widescreen, flatscreen, oversized computer monitors? I sure don’t. But my great-great grandfather’s diary mentions that in the dark ages, television channels weren’t broadcast digitally. I personally find this hard to believe.

However, apparently there existed something called “static” that would occur when the electromagnetic radiation emitted by the television outweighed the meaningful signal being received by the antenna. The end result of this was a seemingly random pattern of flickering black and white. For some people it was quite annoying, but for some people it was actually interesting to watch. With digital broadcasting, when the signal is lost, the image blocks up and stutters, but the effect isn’t anywhere as interesting as it is when analogue is involved.

So, while there are various ways to generate a static noise pattern with video editing software such as Sony Vegas, using video editing software to create video would  make too much sense for my purposes. Also, Sony Vegas is not RIDICULOUSLY EXPENSIVE enough.

Anyway, on to the actual interesting part.  There are two ways to actually accomplish this, but they are basically the same: the only real difference is the number of files generated and which program actually does the video authoring.

The basic theory is this: use a random number generator to generate a matrix of values that can be interpreted as an image. If we take the simplistic view that an image is simply a 3 dimensional matrix of the type mxnx3, where m is the height of the desired image, n is the width and the 3 allows each pixel to have an R,G,B value, this makes figuring out the parameters easier. Because we want greyscale static, the R G and B values will be identical for each pixel: this conveniently saves us a fair amount of computation because we only really need to compute one matrix for each image rather than three.

Pointless exposition aside, (I just wanted to make myself look smart, forgive me if I failed), we’ll start with the messy method.

%start a for loop, designed for 30 seconds of video at ~24fps
for i = 1:24*30
%make a random matrix, in this case it will be 720x480 (wxh)
randmat = rand(480,720,'double');
%make it 3D, and greyscale
Y = cat(3,randmat,randmat,randmat);
%set up a variable so each image will have a different name, e.g. static0001.bmp
imout = sprintf('static%04d.bmp',i);
%write the image to the active directory in matlab
imwrite(Y,imout,'bmp');
end

WordPress does a pretty grand job of derping up any formatting whatsoever, and I haven’t found a way around that without plugins, which I can’t use.

This is the messy method because it will generate 740 independently named bitmap images to your active directory (or more if you increase the length of the loop). The reason for exporting them with this naming system is simple: so we don’t go insane trying to import them into avisynth, which is the next step. The avisynth script is a whopping one line long:

ImageReader("drive:\path\to\MATLAB\static%04d.bmp",start=1,end=740,fps=24/1.001)

This tells ImageReader to look for a pattern that follows the exact same pattern we used to name the bitmaps, which is pretty convenient. This will load each image as an individual frame and set the framerate to 24/1.001 fps, progressive ntsc. Now all that’s left is to encode. Simply add converttoYV12() and throw it at x264. I recommend crf0 because not encoding it losslessly would be silly. Or if you care about decoding speed, you could encode it to an uncompressed rgb avi with virtualdub pretty easily.

The less messy method is second for a couple of reasons: 1) it requires the latest version of MATLAB (r2010b) and 2) it has a strange issue that I am too stupid to fix.

%declare the video object and compression type
video = VideoWriter('static.avi','Uncompressed AVI');
% Set the frame rate.
video.FrameRate = 24/1.001;
%open for writing
open(video);
%set up the loop
for i = 1:24*30
%make a random matrix
randmat = rand(480,720,'double');
%make it three dimensional, greyscale
Y = cat(3,randmat,randmat,randmat);
%write matrix as a video frame
derp = im2frame(Y);
%write frame to video file
writeVideo(video,derp);
end

As you can see, the contents of the for loop don’t change much at all. The VideoWriter class requires MATLAB r2010b or later, and the error in the script is that for some reason or another, it does not finish writing the video file until you close MATLAB. It throws the following warning:

Warning: Direct access of structure fields returned by a function call (e.g.,
call to static) is not allowed. See MATLAB 7.10 Release Notes, "Subscripting Into Function Return Values" for details.
??? Attempt to reference field of non-structure array.

Since the output seems fine and I can’t really see why this warning shows up (it does on the first method as well). Perhaps someone more acquainted with MATLAB would be able to figure it out, but since the output is fine, I don’t really care that much. This method is faster since you don’t have images out the wazoo, and the clip is put together on the fly. Abrupt ending.

A Morose Return to Everything We Never Loved.

A couple of weeks ago, it was that time of year. Yes, I’m talking about that time when all the college students who go to quarter schools realize that  though they’ve been gloating at their semester based peers who’ve been in school for nigh upon a month already, their summer has completely evaporated. The ultimate result of this  is that all the students must make a mass exodus from their homes, streaming across the nation in cars and planes to reach their individual schools, each a nexus of  technology, learning and culture. That is, of course, except for those who attend junior/community colleges. They’re lucky because they don’t have to bother moving several metric tons of junk several metric miles (clever joke amirite) only to realize that they’ve forgotten the single thing they actually needed.

But enough about third person scenarios and sweeping generalizations. This is my blog and I know everyone’s here to read about me, so I’m just going to go ahead and write about HOW INCREDIBLY INTERESTING AND AWESOME AND JUST ALL AROUND ADVENTUREFUL AND CEASELESSLY FULL OF EXPLOITS WORTHY OF EXHAUSTIVE DETAILING THROUGH TEXTUAL MEDIUMS.

For some inane and completely inexplicable reason, classes started on a Thursday. Fortunately for me, Thursday is one of my easier days, consisting of a morning lecture followed by an evening lecture. Over the summer, I had become accustomed to a schedule that would actually have been pretty normal, were I trying to emulate a European time zone. Shifting from repeatedly staying up all night and sleeping all day to having to wake up at 7:30 am for lecture probably could have been a bit more smooth, but the only real hitch was finding out that the cafeteria doesn’t open until 9:00, meaning I’m going to be spending a whole quarter attending early morning lectures on a sleep deficit without breakfast. Adding to this misfortune is the fact that as I’m blearily stumbling in the general direction of the lecture hall, I realize that the path is completely up hill.

It’s around this time that it occurs to me that I’m going to remember this quarter as the one where I had to make a 15 minute uphill walk to an 8:00 am lecture 2 times a week with no breakfast running on 5 hours of sleep.

Under such delightful circumstances, I reach my destination and plop down in a chair in the corner. By the time lecture is supposed to start, the hall is so full of students that many of them are sitting on the stairs between the seats, and even those overflow into a few who are forced to stand awkwardly at the back.

As I slouch in my chair waiting for class to begin, I keep glancing at my watch in the thoroughly misguided hope that it will somehow ward off the somnolence dulling my brain. The chattering of the other people in the room blends into kind of a fuzzy white noise, wiping out any hope of rational thought. As I’m about to lose my feeble grasp on consciousness, the side door dramatically bursts open.

With the way the day had been going up to this point, I didn’t really have any expectations. I would’ve probably even said that I doubted I would be surprised by anything else. Fortunately for me, I never ended up saying that, because I would’ve had to eat my words.

As the professor walked into the lecture hall, it was hard to say which particular feature of his appearance was the most striking. I would argue that the first thing I noticed was the strangely pointed hat perched crookedly upon his head, with wavy white hair shooting out from beneath it that curved around his jawline. Upon a second take, I realized that the beard and hair were in fact a wig, confirming my suspicions that his face looked a little young for him to be sporting such hair color.

By this time, however, my attention had been drawn away from his facial facade to the grey coat that he was wearing that swept along the floor behind him as he walked. I suppose the word “coat” doesn’t quite give the right mental image as to what it looked like, but as far as technical accuracy, that’s exactly what it was. I suppose he had to look for a while to find one that was large enough to drag on the ground behind him while he walked.

The single most impressive aspect of his attire, and ironically the one I noticed last, was the giant, knobby walking stick he carried with him that was about as long as he was tall. It looked like it could have been the most majestic piece of driftwood on the seashore at one point in its life. This was definitely a solid hunk of dead tree, and I recall being glad that corporal punishment hasn’t been used in schools for quite a while.

In his strange attire, he strode swiftly to the center of the room and turned to face his new students. With an arm gesture that I honestly doubt I’d ever be able to repeat, he swept his coat back, causing it to flutter as if blown by a mild wind, and in one smooth movement raised both arms above his head, his glorified piece of driftwood clutched tightly in his left hand. In a gruff tone that seemed trapped between a shout and a growl, he addressed his class for the first time.

“You shall not pass!”

Short addendum directed at any concerned individuals who happen to be my parents: this anecdote contains no falsehood whatsoever. The events of my first class of the year played out exactly as I described them here, much to my chagrin. Also, I have the same professor for all four courses. Hopefully you will be able to understand that I had no control over the circumstances when you extort my grades from me at the end of this quarter. Thank you very much.

Enter title here

So I told myself that I was going to add a new post on here, but it’s late and I need to get to sleep, so this may turn out to be a short, bizarre post. Let’s see how fast I can ramble something out here.

The planned topic of discussion is “stuff that I don’t understand.” Of course, if we were going to sit around and discuss everything that I don’t understand, we’d be here for eternity and a half, which, while I’m sure it would probably be quite enlightening, might be a bit difficult to fit into the average person’s schedule.

That said, I was contemplating the deeper mysteries to life today (as I tend to do so incredibly frequently) and  thinking about random things, I stumbled upon something (I considered) interesting.

In highschool, everyone is basically a gigantic jerk. The social interactions of students are divided up into small cliques, some which get along, but most of which, generally speaking, tend to stay quite separate from each other. People will refuse to get along with other people just because they’re from a certain clique, and throughout highschool, a lot of really stupid drama spawns from this division of social groups.

Then, when you go to college, that pretty much all disappears. People more or less all get along with each other, and when they don’t get along, rather than having huge drama and problems about it, they just ignore each other and everyone goes along their merry way. Perhaps part of the cause of this is because colleges tend to be bigger than high schools, so there’s more breathing room for people to ignore each other.

Another possible reason is that people are getting out of their angst filled teenage years, and that they are finally beginning to move away from home and toward independence. With this increased independence and freedom comes a lack of pressure to rebel against… well, just about everything.

That said, college students can still be impressively immature, and there’s not really anything that makes them better than high school students other than the fact that they managed to get through four years of their life without managing to kill themselves or achieve debilitating brain damage.

Now that we’ve covered an actual topic in this post without deviating too far from sanity and logic, I feel like I should take a paragraph or two and use them to spiral downward into insanity. Actually, I’m pretty sure I’m tired and I don’t really want to stay up any longer, but that’s not the point.

Or maybe it is the point. I feel like this is a really dumb and boring blog post, but I really don’t have anything else to add to it. I haven’t been doing anything particularly technical lately, and even if I had, I doubt I’d have anything intelligent to say about it. Maybe I’ll put an actual interesting post on here one day, but if I were you, I wouldn’t look forward to it.

And, as a closing note, Magnum Opus is really awesome.

A glimpse from here to infinity

So I told a bunch of people that I would post this post a long time ago, and, in fact, the previous post I made may indicate that I’ve had it in mind for a while but have not actually succeeded in accomplishing the post.

So, before I actually start talking about what I’m going to be talking about, let me share one of my largest insecurities with you, the internet at large. One of the things that scares me the most is the thought that there is a generation of people growing up who will never know what analogue static on a television looks like. The standardization of digital broadcast means that when the signal received is subpar, it gets digitized rather than fading out into crackly static. It’s kind of creepy to think that all of these people who will have their own cellphones and computers from age five and up will not ever be able to fully understand the advantages (and disadvantages) inherent in analogue transmission (since radio’s been obsoleted by the internet).  Maybe I’m crazy. But that’s the way I see things.

Continue reading ‘A glimpse from here to infinity’

Space filler

Space filler while waiting for me to write a new post.

Tomorrow, if everything goes well.

Something that everyone’s been looking forward to!

That’s right! It’s the legendary post where I don’t complain about about stuff I hate, I blabber about stuff I like to the point where I make myself seem like an idiot. Or at least that’s what’s planned. We’ll see how well this actually goes seeing as I only seem to post on here when it’s 2 AM or later, which does give me a bonus my coherence roll. I mean, there I go making stupid roleplaying jokes already. And it wasn’t even a good one.

So anyway, I thought I’d get up on my little soap box here and wax eloquent about my favorite genre of creative… creation (utilizing my vocabulary skills, I am), science fiction. In my experience, there are many different types of science fiction, but generally speaking, they can be filtered into two basic (and incredibly general) categories.

The first one is science fiction that tells stories about the future. This category allows the author to create whatever sort of universe they want to, whether that is grounded in scientific principles, or, more often than not (seeing how it requires much less knowledge and/or research), grounded in vague statements that sound fancy but really mean nothing.

The second genre would be (and you’ve probably figured this out using the process of elimination) stories of the past.  This genre is what many steampunk stories fall into, and I usually think of it as sort of a fictional revisionist view of scientific history.

At this point, this post is probably getting you to say “well this is interesting (or perhaps not interesting at all) but what is your point for writing it, and moreover why am I still reading it?” I don’t know why you’re still reading it. I’m not sure why I’m still writing it. I’m pretty sure I’m going to ramble myself to the point where I can’t ramble any more and then just leave it with some sort of dead ending that leaves no one satisfied. Or perhaps I will change the direction entirely.

Now that I have your thought process nicely derailed, these categories end up appealing to me as a reader (and as a person who pretends to have a brain) for very different reasons. For reasons that I don’t actually have, I will now refer to future oriented science fiction as prospective and past oriented science fiction as perspective. Anyway, prospective sci-fi is interesting from the standpoint of seeing the author’s perspective on the future. Something like The Forever War provides a very interesting view on possible (although improbable) evolutions of society. Perhaps a perspective sci-fi equivalent would be something like A Brave New World.

Now you can see I have hit peak ramble when I say something like: that comparison brings up an interesting question. Without doubt, when novels like 1984 and A Brave New World were written, they were definitely prospective as opposed to perspective (although 1984 was trying to be based in the present more than anything), but nowadays, their stories seem based in the past (especially something like 1984 that sets a definite date for its events). This brings up the question of whether we can change which category we fit our science fiction stories into over time, or whether we have to consider what they were when the author wrote them. For example, we have Planetes that is set in the quite near future. In the 2070s (assuming earth isn’t annihilated in 2012), Planetes will be a story about the possible present, and after that, it will merely be a story of a possible past. Ultimately, I think it makes more sense to judge the works based on our frame of reference rather than the author’s intent. At this hour, I don’t really have a decent rationalization for why that is. Perhaps I will be able to come up with one later. Suggestions are welcome, seeing as how my sanity is not likely to come back anytime soon.

Back to the topic that we were talking about before I started talking about things that were not the things I was initially talking about. Perspective sci-fi has a different sort of purpose rather than simply showing off the author’s imaginative prowess. Don’t get me wrong, it requires just as much creativity as prospective sci-fi, but rather than attempting to create a framework for the universe it exists in, it actually builds its own universe inside of a pre-existing framework. Perhaps you agree with me, perhaps you don’t. This is simply my 3 AM ideas on the subject, and I’m sure I’ve done worse than a terrible job of explaining my thoughts.

Well, that’s about all I have to say for now. Perhaps (if you even read this far) in the next blog post, I will actually have something to talk about. But don’t expect it. Final note: I did no quality checking on this, so I can’t promise that all of the sentences are grammatically correct or make sense. Happens with most of the stuff I write. I’ll fix errors as I see them.

This is why I can’t have nice things.

So, apparently, the story is that I suck at letting things go or something. Well, not really. Basically, I felt like if I was going to make statements regarding the competence of people who would not track down actual FLAC releases of their music, I might as well show that I was at least semi-competent. So I went and tracked down all of the songs of Toho Kinema Kan ~2nd curtain~ in their original, lossless incarnations, transcoded them from TTA to FLAC (since FLAC -8 is basically negligibly larger than TTA files, and FLAC has a lot more support as far as playback (and ease of use) is concerned). I may upload all 4 whole albums later depending on how much I feel like it.

I have uploaded the four songs from Toho Kinema Kan ~2nd Curtain~ to mediafire in FLAC format.

In the other news, I got Classic Dungeon: Fuyoku no Masoujin (which for some reason wikipedia refuses to admit exists) to work on GEN 5.50-D3 firmware. The game requires 6.20 (or 6.10, one of the two) firmware, and GEN 5.50-D3 can only play games up to OFW 6.00.  Using Promethius, the patched ISO runs pretty fine, and I haven’t run into any problems yet except for the fact that I don’t speak Japanese. I love retro-style games, though, so hopefully I’ll have a bit of fun playing this. I’d post my patched ISO, but that’d be illegal </irony>.

I think stealing copyrighted material from Japan is my hobby or something >__>

Slowly Coming to Life.

So I released my english subs of Toho Kinema Kan ~2nd Curtain~ to nyaatorrents and the world on Tuesday, June 1, 2010, at around 3 AM (although nyaa disagrees on the time). This is basically the first subbing work I have done (although I had familiarized myself with Aegisub in the past), and I hope it turned out well. You can see the original release notes here, although I did forget to include in them that finding free Japanese fonts is nigh impossible. That was a large source of frustration in compiling this project. I hope you appreciate my effort. Especially since you can just demux them, and BAM, free fonts.

Despite that and the title of this blog, I’m really not actually Touhou obsessed. It is, however, an undeniable part of Japanese popular culture, and while I may have a bit of an unhealthy fascination with that, I’m nowhere near as interesting about it as most of the other people out there who have blogs.

I used to think you had to be good at something to have a blog, because for me, people who can talk about things in an authoritative and engaging manner are much more enjoyable and interesting to read than people like me, who not only don’t have an area of expertise, but also aren’t particularly passionate about the things they like. Actually, I’m pretty sure I still think that. Regardless, it’s nice to have a place to just talk about things. And if you happen to like (or hate) what I say, then I suppose I’ll have done a better job than I expect.

Basically, the impetus behind my creating this is that I have developed the philosophy that if you really like something one (or both) of two things will happen to you. Either you will be compelled to emulate the things you enjoy and respect, or you will be compelled to expand upon them. And so, in light of that philosophy, I have decided to become more active in how I approach the things I enjoy.

We’ll see how this goes.

Hello World

Everybody knows that Blogger blogs are warez blogs and wordpress blogs are anime blogs.


I can put anything here I want.

Except for the stuff it won't let me put here.