stuff Repository
diff 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 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/midi/chgvel.c Thu Apr 07 23:38:12 2011 -0400 1.3 @@ -0,0 +1,47 @@ 1.4 +/* 1.5 + * Copyright (C) 2010 Gregor Richards 1.6 + * 1.7 + * Permission is hereby granted, free of charge, to any person obtaining a copy 1.8 + * of this software and associated documentation files (the "Software"), to deal 1.9 + * in the Software without restriction, including without limitation the rights 1.10 + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 1.11 + * copies of the Software, and to permit persons to whom the Software is 1.12 + * furnished to do so, subject to the following conditions: 1.13 + * 1.14 + * The above copyright notice and this permission notice shall be included in 1.15 + * all copies or substantial portions of the Software. 1.16 + * 1.17 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1.18 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1.19 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 1.20 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 1.21 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 1.22 + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 1.23 + * THE SOFTWARE. 1.24 + */ 1.25 + 1.26 +#include <stdio.h> 1.27 +#include <stdlib.h> 1.28 +#include <string.h> 1.29 + 1.30 +int main(int argc, char **argv) 1.31 +{ 1.32 + char buf[1024], *v; 1.33 + int red; 1.34 + 1.35 + if (argc != 2) { 1.36 + fprintf(stderr, "Use: chgvel <1/reduction>\n"); 1.37 + return 1; 1.38 + } 1.39 + red = atoi(argv[1]); 1.40 + 1.41 + while (fgets(buf, 1024, stdin)) { 1.42 + if (strstr(buf, " On ") != NULL || strstr(buf, " Off ") != NULL) { 1.43 + if ((v = strstr(buf, "v=")) != NULL) { 1.44 + sprintf(v + 2, "%d\n", atoi(v + 2) * (red - 1) / red + (128/red)); 1.45 + } 1.46 + } 1.47 + printf("%s", buf); 1.48 + } 1.49 + return 0; 1.50 +}
