stuff Repository

annotate midi/chgvel.c @ 94:779015292fac

Yet more log format improvements.
author Gregor Richards <Richards@codu.org>
date Thu, 07 Apr 2011 23:38:12 -0400
parents
children
rev   line source
Richards@61 1 /*
Richards@61 2 * Copyright (C) 2010 Gregor Richards
Richards@61 3 *
Richards@61 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
Richards@61 5 * of this software and associated documentation files (the "Software"), to deal
Richards@61 6 * in the Software without restriction, including without limitation the rights
Richards@61 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
Richards@61 8 * copies of the Software, and to permit persons to whom the Software is
Richards@61 9 * furnished to do so, subject to the following conditions:
Richards@61 10 *
Richards@61 11 * The above copyright notice and this permission notice shall be included in
Richards@61 12 * all copies or substantial portions of the Software.
Richards@61 13 *
Richards@61 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Richards@61 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Richards@61 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Richards@61 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Richards@61 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Richards@61 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
Richards@61 20 * THE SOFTWARE.
Richards@61 21 */
Richards@61 22
Richards@61 23 #include <stdio.h>
Richards@61 24 #include <stdlib.h>
Richards@61 25 #include <string.h>
Richards@61 26
Richards@61 27 int main(int argc, char **argv)
Richards@61 28 {
Richards@61 29 char buf[1024], *v;
Richards@61 30 int red;
Richards@61 31
Richards@61 32 if (argc != 2) {
Richards@61 33 fprintf(stderr, "Use: chgvel <1/reduction>\n");
Richards@61 34 return 1;
Richards@61 35 }
Richards@61 36 red = atoi(argv[1]);
Richards@61 37
Richards@61 38 while (fgets(buf, 1024, stdin)) {
Richards@61 39 if (strstr(buf, " On ") != NULL || strstr(buf, " Off ") != NULL) {
Richards@61 40 if ((v = strstr(buf, "v=")) != NULL) {
Richards@61 41 sprintf(v + 2, "%d\n", atoi(v + 2) * (red - 1) / red + (128/red));
Richards@61 42 }
Richards@61 43 }
Richards@61 44 printf("%s", buf);
Richards@61 45 }
Richards@61 46 return 0;
Richards@61 47 }