Categories
Computing

Muster 005 DC: Experience

Most photos from Jocko’s Twitter feed

If you don’t know who Jocko Willinck is, here’s the synopsis. Born and raised in New England. Dreamt of being a commando (his words). Became one as a Navy Seal. Fought in Ramadi, Iraq in 2006 in what is known as the Battle of Ramadi where fighting was considered to be the worst.

Helped turn around that city. A report cited by the Washington Post, known as the Devlin Report, stated that the city was essentially lost.

Jocko is highly respected for his leadership style which he distilled for the SEALs upon his return from Ramadi. He served as the Officer-in-Charge of training for all West Coast Seal Teams. Has a number of books on leadership, books for young people. Well-known for his podcast. (There are links at the end of this post to help you find free and paid materials.)

Jocko assembled a team of military leaders as consulting firm (Echelon Front) to train non-military about leadership concepts.

The answers to questions regarding leadership apply across race, gender or any other difference you may want to consider.

This article is NOT about the concepts discussed at the Muster. Those concepts are easily found in Jocko’s podcast, his books, and his Twitter feed. Many are free. Musters are not free, but I recommend them highly for a deep dive.

One interesting thing I came across is that a number of people who were there that self-funded the conference. Companies perhaps don’t get it. Jocko and team are quick to point out that you may want to apply what’s learned and not necessarily mention the military antecedent. Having those ties might create unnecessary resistance — the goal is effective leadership, not an advertisement for Echelon Front or Jocko.

This article IS about the actual Muster experience. That’s something you might not necessarily get elsewhere.

Day 1 PT

At 4:25, I leave my hotel room to head to morning PT, optionally offered to all attendees. I don’t particularly do well getting up and “getting after it” as Jocko would say, so I rise at 3:30, make some hotel room coffee and grab a quick shower. At 4:30 am, I head down. In the tunnel connecting the hotel to the adjacent underground mall, there are already 200-300 waiting to go do burpees, jump squats, push-ups, flutter kicks, arm-somethings, and sit-ups. (In the picture below, note the picture of Jocko lined up with ready and willing participants.) By the time we head out, 400 people are lined up. The rain is “no factor”. The workout starts at 4:45 am. Each set is two minutes. You get 30 seconds of rest in between each set. Rest means you do jumping jacks. Do that twice. At least one person who looked to be in great shape was puking afterward.

DdaIo3xWkAE3mSR

Then Jocko mentions that there were 14 officers killed last month in the US. 400 people do 14 burpees.

Essentially 30 minutes of constant work, plus burpees.

OK. Now you’re done.

Don’t let that scare you off. People of every age, size, and sex were represented and did well.

Maybe you’re better than you thought. You just needed someone to point it out to you.

400 people walk back to the hotel greeting early-morning dog owners. I’m not sure they knew what to make of us.

Day 1 Morning

The doors to the conference open at 7:45 am leading to the large hall filled with video screens and conference room tables. Waiting for you are two booklets with much of the conference content. I brought my own small notebook and recommend doing so. I made quite a few notes and starred those things that I need to work on.

I sat next to a gentleman and struck up a conversation.

Me: What do you do for a living?

Him: (I’m paraphrasing and summarizing.) I’m a director for a company that supports organ transplants and donations. We match those who can donate organs with those in need. It’s an extremely time-sensitive effort, as you can imagine. I’m here to better learn how to support my team.

This is the type of story you’ll hear from people at this conference. Some of these people do incredibly important work. Everyone is highly motivated to lead better. I didn’t speak to one person who said they came because this was a track to a promotion. Every single person seemed driven to lead more effectively. Absolutely driven.

The morning is incredible, as you might imagine. We’re introduced or re-introduced to the Four Laws of Combat. The real-life combat scenarios and the ensuing lessons learned by Jocko and his team are covered. These are not your typical business scenarios. These are life-and-death situations where there’s not always a happy ending. This is NOT a feel-good conference. Despite the outcome, there is always a lesson learned. That lesson is always applicable to other scenarios. The lessons are sobering because of the loss of human life, people denied basic decency and the oppression of a population.

This video introducing the 2016 Muster from two years back gives you a good impression of what to expect.

Day 1 Lunch

The food at The Muster was meant for athletes. So, not your typical conference food. There is plenty of protein (steak and chicken); there are plenty of greens (4 kinds of lettuce, plus healthy toppings). You can find some healthy carbs too. The one table I saw with slices of cake seemed to be basically untouched.

There was an interesting conversation going on at my lunch table. These tables seat around 10-12 persons and were covered in white tablecloths. One of the gentlemen at my table was, based on his shirt and conversation, clearly helping to run the conference.

He mentioned in no uncertain terms that this is one of his favorite conferences. That was due not only to the subject, the presenters but also because of the attendees.

“Everything starts on time. Everyone is extraordinarily courteous to my staff. Jocko knows what he wants and asks for it.”

It’s true. Given other conferences I’ve attended, there is a noticeably different vibe to this conference. People are very courteous. People line up early to get in hoping to get a great seat; there isn’t any cutting in front of others or pushing. Everyone is extremely polite.

Attendees would line up during breaks to get their books personalized by Jocko and Leif. Jocko and Leif would pose with the attendees for quick photos. Near the end of a break, the lines were not quite exhausted. A staff member would inform those still in line that they would need to try again later. No complaining or whining. People get it.

Jocko and Leif also tirelessly spend time meeting with those who have a great interest in this subject. It didn’t seem like they were taking any breaks.

32702596_4141764645960921_7917732348584525824_o

I mention to my wife that this seems to be a conference of biceps and tattoos. As is my experience in other areas of my life, these are among the most well-behaved people walking around.

Day 2 PT

Day 2 PT was easier. Well, until the next day.

AMRAPs. 20 minutes. Lunges, push-ups, squats, sit-ups. Do as many sets of 10 as you can. I got through 10 plus sets in 20 minutes and had started 11. So, 100 of everything. That was my goal, but certainly less than what was being encouraged. (The goal was 1 set per minute.)

Before beginning, Leif Babin announced that there was one “puker” yesterday.

He’s hoping for three today.

No one takes offense at this, or should. If you’ve ever pushed your limits, puking is certainly possible.

The team of SEALs is walking around encouraging people and joking with those they know to be ex-military.

32686206_4142595202544532_8587354884318167040_o

A bunch of out-of-shape business people (even in this crowd) get just what they need to challenge themselves. And they do. The gentleman next to me appears to be in his early 60s. No factor. The young lady in her 20s next to me is excited afterward to tell me that she did 10 sets and didn’t think she could ever do 100 push-ups.

As we’re exercising, in the background I hear, “that’s not a rep, Marine. One. One. One.” Clearly, he’s talking to someone he knows to be military. It’s all good-natured.

The rain I feel is truly a gift. I remove my cap after a few sets since I’m sweating quite a lot even with the temperature in the mid-60s. The cool rain feels great — any thought of getting drenched is replaced by gratitude for the light rain.

So, I’m feeling pretty good about the 20-minute workout, my pace and being able to finish strong. We practice finishing strong in Muay Thai and my last set of push-ups is no problem.

We approach the stand. Leif comments that we’re going to do “one more thing” and it begins with a “B”. Someone chimes up “burpees?”.

“Nope. We’re going to bear crawl across the soccer field.” Thankfully, he means across, not lengthwise. That means, assuming a conventional soccer field, we’re likely to bear crawl half of a football field. (Bear crawls happen to be one of my least favorite things.) I get behind some folks who occasionally drop to their knees and stop. For this, I am grateful. I make it across and watch those behind me finish.

There is one gentleman making his way across the field after all have finished. He is struggling but persisting. Someone (presumably from Jocko’s team) runs out on the field not to yell, but to encourage. That team member drops down next to our final athlete and does the bear crawl with him. All of us on the sidelines are cheering and clapping. We’ve all been there — normally without 400 others looking on. As this person crosses the sideline, he’s greeted generously by a host of people.

Each day, the walk to PT is interesting. Nothing about walking, but everything about people. I try to strike up a conversation both ways and doing so is really easy.

On the way to PT on Day 2, I spoke to a firefighter from Maryland. He’s a young officer, with a six-year-old child who does jiu-jitsu and loves it. This officer, like me, is there on his own dime and is quite grateful for the discount Echelon Front offers him (as a first responder, deeper than my early bird discount, as it should be). He gets how important all of this is and like everyone there is motivated to be a better leader. He looks like a bit of a bad-ass, but as I discover from our conversation, he’s really friendly and a little shy.

On the way back, I chatted with someone running training programs professionally. In contrast to the firefighter, his company has embraced Extreme Ownership to the point where they’ve purchased books for their staff and are sending him to check out the program to determine if others from his company should go. And oh, by the way, he is former military, was in Afghanistan during the late 2000s and trained bomb dogs.

When I tell people what I do, they don’t typically get it. “I work for a Real Estate Investment Trust supporting their technology efforts”. I always feel a bit embarrassed. Here you are saving lives and well, I do this thing where we just try to provide a great place to live and make money for our shareholders.

As I learn later in the conference, Jocko and team don’t necessarily see what you do as a reason for embarrassment.

At the end of the conference, they refer to the economic power of the United States as critically important. They don’t see themselves as better, and they don’t necessarily see others as lesser. The power of the economy in the world is strong a necessary for influencing freedom.

While I was walking with my bomb-dog friend, we happened behind Rob Jones. If you don’t know who Rob Jones is, check out his site. More reason to be humbled. Mr. Jones served as a Marine Corp combat engineer and lost his legs. Like the rest of us, he went to the morning AMRAP workout (lunges, push-ups, squats, and sit-ups in sets of ten, as many sets as possible for 20 minutes.) Except he has prosthetic legs.

32951047_4143002865837099_5519873603539042304_o

This makes me realize how really lazy, whiny and self-centered most of us are. As we’re walking, I realized Mr. Jones was chatting with Dave Berke who is a real-life Top Gun; he was a Top Gun instructor and is a member of the Echelon Front team. (The attendees kidded Mr. Berke during his presentation on Thursday that he was the real Maverick from the movie Top Gun.) In addition to being an instructor at Top Gun, he found time to get a Master’s from Johns Hopkins School of Advanced International Studies with a concentration in Strategic Studies.

What you might get out of the conference

In addition to the two days at the conference, I spent my short flight home (1.5 hours) and much of the next day reflecting on areas where I can make improvements with my team.

As mentioned earlier, this is not a feel-good conference. You’re asked to consider how you can improve as a leader in light of the lessons learned by Navy SEALs. Everyone walks away with ideas for their improvement. Certainly, that’s why you would attend.

Concepts that I have applied have worked remarkably well. In fact, on a recent project, there was a lot of excitement surrounding the project itself where these Extreme Ownership principles were applied.

In the least, what you’re likely to walk away with are two provided notebooks summarizing the conference ideas. If you take notes yourself, you’ll also have plenty of items to go back and consider. It’s likely weeks or months of incremental improvements you can make for yourself and your team.

Resources

Online

Jocko Podcast

Jocko Podcast on YouTube

Jocko Podcast “Good”

Jocko Podcast “Sisyphus”

Echelon Front

Written

Jocko’s Amazon Page

 

 

 

 

Categories
Computing

A Look at Elastic Beanstalk’s Launch Activities

Using Elastic Beanstalk makes it easy to spin up a Web or Worker Application. If you’ve done so manually, you can really appreciate the fact that AWS can consistently create a working environment.

In this example, we’ll review the major steps that occurred while spinning up a sample .NET web application. 11 steps were output to the console over a 20-minute period.

  1. createEnvironment message.
  2. Specified an S3 storage bucket for environment data. Noted that this bucket was now associated with my account. The bucket creation date was 6/19/2016 which is almost a full two years prior to creating this site.
  3. Security Group created.
  4. Created an Elastic IP.
  5. EC2 instance waiting message.
  6. Adding specific EC2 instance message.
  7. Added EC2 instance to Auto Scaling Group.
  8. Started Application message.
  9. UpdateAppVersion Completed message.
  10. Environment Health to green message.
  11. Successful launch message.

Once created, I clicked on the available URL and noted the working web application.

My next step was to delete the application and to observe whether the Elastic IP, EC2 instance, Security Group and Auto Scaling Group were all removed. They were and I noted the following:

  • the EC2 instance had as its name tag, the name of the website created. It was showing as terminated in the Console.
  • the S3 bucket persisted in my account.

 

Feature Photo by Joel Filipe on Unsplash

 

Categories
Computing

grep your EC2 Instances in a Region Using the CLI

Assuming you have the AWS CLI installed, you can easily grep instances in a Region. To see your Default region name, type aws configure and hit Enter twice.

To allow grep to work nicely with the output, enter “text” for the Default output format

aws configure
AWS Access Key ID [*******************]:
AWS Secret Access Key [*******************]:
Default region name [us-west-1]: 
Default output format [text]: text

In this example, we’ll show basic instance information such as the name of the Reservation, the State and the StateReason. We’ll use grep’s OR operator.

aws ec2 describe-instances | grep 'RESERVATION\|STATE\|STATEREASON'

The CLI will respond with something like the following:

RESERVATIONS 123222575111 r-0c1xbac1122y90121
STATE 80 stopped
STATEREASON Client.UserInitiatedShutdown 
Client.UserInitiatedShutdown: User initiated shutdown
...

At a glance, you can easily inspect all the EC2 instances in your Region.

Feature Photo by Hendrik Morkel on Unsplash

Categories
Computing

Passing the AWS Associate Exam

Looking for advice on passing an AWS Architecture Associate Exam? I had been looking for that advice very recently. Fortunately, there are plenty of good resources out there to help. (And yes, I did pass the exam recently.)

Advice isn’t in the form of exam answers. Well, it is if you’re willing to dig in.

I followed four tiers of study. You don’t need all four. You could do only Tier 1 and likely do great on the exam provided you dig into the tests as recommended.

Tier 1

  • linuxacademy.com — after each module, take the quizzes. Once you’ve worked through everything,  take the exam either timed or not. The questions are NOT the questions on the AWS Exam, but they are really helpful. The most important thing you can do is dig into all the answers, right or wrong. Two answers are often reasonably good with the detail of one being incorrect with the detail of another being correct. Those details are important for the actual exam! Understand why the wrong answers are wrong. You may not see the question on the actual exam, but digging into understanding why a certain solution for a problem is not right can help you understand when it is the appropriate choice. Lastly, there is no substitute for taking the timed exams — even in the comfort of your home, you feel a little pressure — that’s a good thing to do.

Tier 2

  • acloud.guru — they also have an exam simulator. I found their courses to be just as good as Linux Academy’s course. The exams were good too. I used their course a little less than Linux Academy.
  • pluralsight.com (Elias Khnaser’s courses)

Tier 3

Two excellent free videos about VPC from re:Invent. (Yes, you can see a LOT from re:Invent without going.)

Both presentations are really insightful. In both cases, the presenters build your knowledge from the ground up. You could watch either one and walk away with a good understanding. I really do like both, and they are well worth your time. I listened to both several times during commutes — not ideal, but helpful nonetheless.

  • Amazon does guide you, to a great extent, in their book AWS Certified Solutions Architect Official Study Guide available at Amazon.Before purchasing the Official Study Guide, read Casey Hendley’s review of the book on Amazon’s site. The book is a little dated given, as Casey says, that “Amazon changes things on AWS at a frightening pace”. I would not use this book alone to pass the exam.

Tier 4 – Immersion

If you can afford it, attend re:Invent or a Summit. I’ve done both multiple times. Immersing yourself in the domain is worthwhile, and if you’re a working professional, hard to do on your own. I burn a week of vacation for re:Invent, spend the money and immerse!

Amazon offered a free HA course in NYC. So, I went and took it. Had a great time both with the course and in the city.

I live in Chicago, so I attended the Chicago Summits in 2016 and 2017.

Washington, DC is awesome, so I went to the Public Sector Summit. Don’t work in the public sector — didn’t care.

Went to re:Invent in Vegas twice. Those are more expensive efforts, but for me, well worth it.

 

(Feature Photo by Ben White on Unsplash)

 

Categories
Computing

SQL Server Date to Varchar Conversion Formats

Often, I find the need for a specific format for a date. SQL has lots of great options with its convert function.

Here’s a handy chart.

select convert(varchar, getdate(), 101) -- 12/23/2015
select convert(varchar, getdate(), 102) -- 2015.12.23
select convert(varchar, getdate(), 103) -- 23/12/2015
select convert(varchar, getdate(), 104) -- 23.12.2015
select convert(varchar, getdate(), 105) -- 23-12-2015
select convert(varchar, getdate(), 106) -- 23 Dec 2015
select convert(varchar, getdate(), 107) -- Dec 23, 2015
select convert(varchar, getdate(), 108) -- 08:32:49
select convert(varchar, getdate(), 109) -- Dec 23 2015 8:33:06:007AM
select convert(varchar, getdate(), 110) -- 12-23-2015
select convert(varchar, getdate(), 111) -- 2015/12/23
select convert(varchar, getdate(), 112) -- 20151223
select convert(varchar, getdate(), 113) -- 23 Dec 2015 08:33:25:220
select convert(varchar, getdate(), 114) -- 08:33:25:220
select convert(varchar, getdate(), 115) -- 115 is not a valid style number when converting from datetime to a character string.
select convert(varchar, getdate(), 116) -- 116 is not a valid style number when converting from datetime to a character string.
select convert(varchar, getdate(), 117) -- 117 is not a valid style number when converting from datetime to a character string.
select convert(varchar, getdate(), 118) -- 118 is not a valid style number when converting from datetime to a character string.
select convert(varchar, getdate(), 119) -- 119 is not a valid style number when converting from datetime to a character string.
select convert(varchar, getdate(), 120) -- 2015-12-23 08:34:39
select convert(varchar, getdate(), 121) -- 2015-12-23 08:35:46.370

Feature Photo by Andrew Neel on Unsplash

Categories
Computing

Using a Correlated Subquery to Update a Base Table

The syntax for updating using correlated subqueries can be a little confusing at times. The example shown below uses a table variable as its target.

The key is to include an aliased version of the table in the UPDATE’s FROM clause.

Once that is aliased, you can simply reference the alias in the subquery.

For example:
UPDATE
    x
SET
    PROJCOMMENTID = 
    (
        SELECT 
            MAX(pc.PROJCOMMENTID) 
        FROM 
            ProjectComments pc (NOLOCK) 
        WHERE 
            pc.PROJECTID = x.PROJECTID
    )
FROM
    @ProjComments x

Featured Photo by Maarten Deckers on Unsplash

Categories
Computing

An Introduction to Writing Externs in C for Max/MSP

Abstract

The target reader of this paper is a Max/MSP user with limited programming experience. This paper analyzes a single sample program adapted from Ichiro Fujinaga’s tutorial on compiling externs using Xcode. Code samples are shown in Xcode, but a variety of programming environments is possible. The example discussed here introduces and explains the necessary framework to begin developing more complex externs. Knowing this framework is extremely helpful in developing externs.

[If you’re only interested in the code discussion and not in getting setup, skip ahead to section 3.]

1 Overview

A language provides a vocabulary and the rules for combining words in the vocabulary. Grady Booch

If we were to apply Booch’s comment to Max, we might first observe that Max has a considerable native vocabulary (sfplay~, ezdac~, ctlin, etc.) and that the mechanism for treating the native Max vocabulary is robust, which in this case is to say that the mechanism imposes few rules. The framework is the blank canvas in Max, do what you want with it. One can simply combine the existing vocabulary in any desired way. Even with that power, Max allows users to further syntactic extension. While creating a specialized vocabulary by writing externs is not necessary for the successful use of Max, it does allow developers the opportunity to extend the vocabulary and introduce new objects to the Max environment.

1.1 Recommended Sources

A word should be said about existing extern development documentation. There are limited, but excellent sources available. Two papers, “Writing External Objects for Max 4.0 and MSP 2.0” [2001] and “Writing External Objects for Max and MSP” [2005], are available from Cycling ’74. Both of these papers are excellent, easily readible and largely cover similar material. In fact, the 2005 version seems to be an updated 2001 version. There are also a number of sources available online at McGill University in Montreal. Ichiro Fujinaga teaches a course there titled Advanced Multimedia Development that focuses on writing externs for Max. As of this writing, Fujinaga has three tutorials available, each for a different version of the Mac/Programming Environment (Classic, OS X & OS X Xcode). There are limited PowerPoint slides from his course and many externs that serve as great examples.

1.2 Development Environment

The subject of development environment is a bit beyond the scope of this paper, but is critical to the success of compiling the code discussed here. In the paper “External Objects for Max and MSP”, Cycling ’74 explains how to write externs using CodeWarrior on the Mac and Microsoft Visual Studio on the PC. One of Fujinaga’s tutorials, “Max/MSP Externals Tutorial: Version 3.1”, discusses using Xcode on the Mac. There is a more recent tutorial at www.cycling74.com, entitled “Writing Externals with Xcode 2.2”. Getting the development environment set up correctly can be challenging.

1.3 Code used in this Paper

The code shown in this paper is taken directly from Fujinaga’s example in his paper “Max/MSP Externals Tutorial: Version 3.1”. The code presented here has been varied slightly. Fujinaga’s paper is largely concerned with getting the development environment setup and does provide an overview of the code. This paper is a bit more in depth (in terms of this single example) and aims to explain Fujinaga’s example in light of other sources, notably Zicarelli and general C programming constructs.

1.4 What you’ll need to compile and run this code

In order to compile and run the code in this paper, you’ll need the following.

1. Max/MSP2

2. The Max/MSP SDK3

3. A development environment 4 that will compile C code. This paper uses Xcode5 on the Mac. You’ll deploy your code to Max’s extern folder and access it similarly to any other Max object.

2 What is an Extern?

An extern, or external, is a computer program, not part of Max’s standard object palette, that will be consumed by Max. The program is in the form of a shared library or dll. The most common language used for externs is C, although a bridge called FlexT is available for C++.

There are two broadly defined types of externs – a normal object and a user interface object. A normal object rendered in Max looks like many Max objects, with either a single or double line both on the top and bottom of the object, inlets and outlets, the object’s name and arguments. A user interface object, beyond the scope of this document, brings its own UI to the table.

Screen Shot 2015-12-13 at 3.53.20 PM

In terms of C code, at a high level, an extern essentially consists of an entry point (the main() function), a description of the object (in the form of a struct) and definitions of functionality (in the form of methods). Certain methods and elements of the struct are required by Max.

3 An Example

Learning the framework of an extern, along with compiling and deployment will go a long way to getting into some more involved projects. The essential structure shown here is relevant to externs generally.

Screen Shot 2015-12-13 at 3.54.33 PM

Figure 2. bang.c Source Code in Xcode environment

Let’s look at this code from the perspective of how Max runs it. Max will load the extern’s code starting with main() – main() provides the entry point for Max to gain access to the behavior you will provide7 in your methods. main()’s job, in the context of this extern, is simply to “initialize its class”. This means that main() is called either when Max loads (if your extern in your max-startup folder) or when
you create an instance of your object at design time in the Max patcher window (this latter approach will occur if
your object is not in your max-startup folder, but is somewhere where Max can find it).

3.1 setup()

As Figure 2 shows, the first line of code in main() calls a function, setup(). If you spend some time coding Max objects, the details of this method call will become very familiar. This method is available by virtue of including ext.h which is the first non-commented line in the source code:

#include “ext.h”

setup() provides Max with the (1) information to find your object (where it lives in memory), (2) the name of your object’s constructor (the housekeeping tasks performed to create your object in memory), (3) the name of its cleanup method (the housekeeping tasks performed to remove the object from memory), (4) the size of its data structure, (5) the name of the method that will define your object’s UI (if you have one – we don’t in this example) and (6) the type list 9 . That may seem like quite a lot, but some of the parameters are optional and can be sent zero values (0 or 0L in the case of a long datatype). In the example above, we only use three of the six available parameters. Moreover, the nasty business of doing object creation and destruction is handled for us in this simple example. That turns out to be quite nice. Here’s the call to setup with the various arguments highlighted:

• the location (address) of your object:

setup((t_messlist**) &this_class, (method)bang_new, 0L, (short)sizeof(t_bang), 0L, 0);

• the name of your constructor (which is going to be in the form programname_new or programname_create):

setup((t_messlist**) &this_class, (method)bang_new, 0L, (short)sizeof(t_bang), 0L, 0);

• a method that will do cleanup; in this case this is pointing to nothing

setup((t_messlist**) &this_class, (method)bang_new, 0L, (short)sizeof(t_bang), 0L, 0);

• the size of your internal data structure (required):

setup((t_messlist**) &this_class, (method)bang_new, 0L, (short)sizeof(t_bang), 0L, 0);

• the name of the method that will define your user interface:

setup((t_messlist**) &this_class, (method)bang_new, 0L, (short)sizeof(t_bang), 0L, 0);

• an argument list you may pass to your class (here again, we are pointing to nothing, or null):

setup((t_messlist**) &this_class, (method)bang_new, 0L, (short)sizeof(t_bang), 0L, 0);

In our example, we’re providing Max with three pieces of information: (1) the object address, (2) the constructor, (3) the size of the data structure. The other bits are not needed, but we still must provide values as this method is not overloaded.

3.2 addbang()

We have one more line of code in our main() method and that line has a simple explanation. It’s important, for the purposes of running our extern, to distinguish between where a certain method is located in memory (accomplished by binding our function) and what that method actually does (accomplished by defining our function). The addbang((method)bang_bang) method tells Max which of our functions to run when our extern encounters a bang. In short, it says, “when my object receives a bang, the name of the method that is to be invoked is bang_bang”. addbang() is likely a method you’ll encounter often when writing externs. addbang() has a number of addsomething() siblings: addfloat(), addftx(), addint(), addinx(), addmess().

If our method name were N_bang, then the syntax for “binding” our method to our implementation is:

addbang((method)N_bang);

The method name for N is normally the name of our program followed by an underscore followed by the word bang. So, if we were writing an object called attenuator for Max and our object needed to accept a bang as input, our method name for handling such input might be attenuator_bang. Similarly, if we wanted methods to handle ints, floats, etc. in our attenuator object, we would have methods such as attenuator_int(), attenuator_float, etc. Typically, we bind these methods to inlets in our main() method.

3.3 Recap

So, in short, the main() routine of an extern is used to bind our methods.

3.4 Implementation

Telling Max how to build our object. In Max, most objects have inlets and outlets. We send messages in, we get something out. Take the ubiquitous notein object, for example:

Screen Shot 2015-12-13 at 4.07.12 PM

Figure 3. notein pictured in the patch from Max’s help on notein.

notein gets its information coming in via the MIDI stream, so there is no visible connector going to an inlet 13 . The implementation of this object, behind the scenes, takes that stream of data, parses it, and outputs specific pieces of data (pictured above). In Max then, we can do something with this data – we can route pitch, operate on the values, etc.

In code, we describe the outlets in our data structure. In our example, that is this:

Screen Shot 2015-12-13 at 4.08.34 PM

You may be asking, “where’s the inlet defined?”. One inlet is automatically created for an object so you don’t have to create one manually in code. This is a nice default since typically we’ll want at least one inlet. It is possible to instruct Max not to create an inlet in your constructor14 . You do need to create any outlets in the struct, however, and you’ll need to declare a void pointer for each outlet. We’ve created two outlets in our example here, simply for the sake of having more than one.

Telling Max about our methods

We’re actually fairly far along in our analysis. Following our typedef, we have prototype declarations for the methods we’ll implement after our main() function.

Screen Shot 2015-12-13 at 4.10.01 PM

Figure 4. Prototypes

Declaring the prototypes is our way of telling the compiler about the methods and appropriate arguments it will encounter before the method’s actual definition. We could put our implementation above the main() function, but we’ll follow the convention here of having the prototypes, followed by main(), following by the method implementation. So in main(), we reference both bang_new() and bang_bang(); however, these methods are not been declared in ext.h and are not native to C, so when we reference them in main(), they don’t technically exist. (Your compiler may not care if you skip the prototype, but it’s strongly recommended that you include prototypes.) The prototypes provide a nice way for us to see what our object has implemented, or at least what we want to implement and what our method signatures will be.

The prototypes outline (but do not define) the methods that tell Max what to do. This implementation is in contrast to our method references in main() that inform Max where to find our methods.

So our constructor, bang_new(void), is a void pointer that takes a void as an argument. That method is defined as this:

Screen Shot 2015-12-13 at 4.11.21 PM

Figure 5. bang_new

Our constructor creates a pointer pointing to our typedef, calls newobject, sets up our outlets (bangout15 ) and returns.We’ll let Zicarelli himself explain newobject:

You call newobject when creating an instance of your class in your creation function. newobject allocates the proper amount of memory for an object of your class and installs a pointer to your class in the object, so that it can respond with your class’s methods if it receives a message.

[Zicarelli, Writing External Objects for Max 4.0 and MSP 2.0, 35]

Our call to newobject refers to this_class. Earlier, we defined this_class as this:

Screen Shot 2015-12-13 at 4.15.02 PM

Figure 6. this_class

In our constructor, bang_new, we’re doing two things: we’re creating an instance of our class, declared as t_bang (and sending it to newobject()), and creating pointers to our outlets. Our outlets send out bangs. They send bangs by calling bangout().

Our constructor is done. Lastly, bang_bang will take our struct as an argument and bind its outlets to outlet_b. outlet_bang, as the name implies, simply sends a bang out the bound outlets.

4 Recap

That’s a lot of information, especially if you’re new to writing externs or programming more generallyScreen Shot 2015-12-13 at 4.16.49 PM. This does cover the framework for creating our extern. If your extern is going to do some sort of machinations to output some value based on a bang, the structure of your extern is not going to differ much from what you see here. For the sake of review, look over the code below again with a brief explanation of each part.

5 Going Forward

The functionality we’ve provided with our extern is certainly nothing you need an extern to do. We’ve received a bang and output a bang. If you can put this code in your favorite editor, compile it and deploy it, you’re well on your way to writing more complex externs. The goal here is to show the structure of an extern and to better understand what’s happening. There are tradeoffs in choosing any language – in terms of creating externs for Max, we have many choices and C is one of them. There are a variety of externs available at the Cycling ’74 website. A quick survey of those externs will show the breadth of what is possible and may give you ideas for some great extern of your own.

Acknowledgements

Howard Sandroff, professor – Music, University of Chicago

Mark Shacklette, adjunct professor – CSSP, University of Chicago References

Dobrian, Chris. Max: Tutorials and Topics. San Francisco: Cycling ’74, 2000. Cycling ’74. 31 Dec. 2005 .

Fujinaga, Ichiro. “Advanced Multimedia Development.” www.music.mcgill.ca. McGill University. 31 Dec. 2005 .
Zicarelli, David. MAX: Writing External Objects for Max and MSP. San Francisco: Cycling ’74, 2005. Max/MSP Software Development Kit (SDK) for Macintosh. 31 Dec. 2005 .

Feature Photo by Kevin Ku from Pexels