Max-MSPでファイルパスを取得し、ファイル名などを末尾に追加する方法。


#概要

sfrecordや、jit.recordなどで、オーディオシグナルや映像マトリックスをファイルに出力して保存したいなどの場合、事前に出力先のファイルパスを設定したいなどあると思います。

その際に、パス取得して、ファイル名を追加したシンボルメッセージが欲しい場合などがあると思います。

ここでは、MaxMSPやMax for Liveでファイルパスを取得して、ファイル名などを末尾に追加する方法を紹介します。


![スクリーンショット 2021-04-29 22.28.47.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/152481/36a8ca1c-baa5-79ff-dc78-73a96623bcee.png)




```Maxmsp
{
	"boxes" : [ 		{
			"box" : 			{
				"maxclass" : "newobj",
				"text" : "sprintf symout %saudio.aiff",
				"patching_rect" : [ 1380.0, 677.0, 140.0, 20.0 ],
				"outlettype" : [ "" ],
				"id" : "obj-220",
				"numinlets" : 1,
				"numoutlets" : 1
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "newobj",
				"text" : "append aiff",
				"patching_rect" : [ 1380.0, 711.0, 62.0, 20.0 ],
				"outlettype" : [ "" ],
				"id" : "obj-215",
				"numinlets" : 1,
				"numoutlets" : 1
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "message",
				"text" : "open \"Macintosh HD:/Users/taito-otani/Downloadsrec.aiff\" aiff",
				"patching_rect" : [ 1273.5, 744.0, 353.0, 20.0 ],
				"outlettype" : [ "" ],
				"id" : "obj-214",
				"numinlets" : 2,
				"numoutlets" : 1
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "newobj",
				"text" : "t b b",
				"patching_rect" : [ 1379.0, 566.5, 30.0, 20.0 ],
				"outlettype" : [ "bang", "bang" ],
				"id" : "obj-209",
				"numinlets" : 1,
				"numoutlets" : 2
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "button",
				"patching_rect" : [ 1427.0, 445.0, 24.0, 24.0 ],
				"outlettype" : [ "bang" ],
				"parameter_enable" : 0,
				"id" : "obj-203",
				"numinlets" : 1,
				"numoutlets" : 1
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "newobj",
				"text" : "prepend set",
				"patching_rect" : [ 1424.0, 566.5, 81.0, 23.0 ],
				"outlettype" : [ "" ],
				"id" : "obj-18",
				"fontsize" : 13.0,
				"numinlets" : 1,
				"fontname" : "Arial",
				"numoutlets" : 1
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "newobj",
				"text" : "relativepath",
				"patching_rect" : [ 1427.0, 531.5, 80.0, 23.0 ],
				"outlettype" : [ "" ],
				"id" : "obj-204",
				"fontsize" : 13.0,
				"numinlets" : 1,
				"fontname" : "Arial",
				"numoutlets" : 1
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "newobj",
				"text" : "opendialog fold",
				"patching_rect" : [ 1427.0, 501.5, 101.0, 23.0 ],
				"outlettype" : [ "", "bang" ],
				"id" : "obj-205",
				"fontsize" : 13.0,
				"numinlets" : 1,
				"fontname" : "Arial",
				"numoutlets" : 2
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "newobj",
				"text" : "filepath search 4",
				"patching_rect" : [ 1379.0, 602.5, 220.0, 23.0 ],
				"outlettype" : [ "" ],
				"id" : "obj-208",
				"fontsize" : 13.0,
				"numinlets" : 1,
				"fontname" : "Arial",
				"numoutlets" : 1
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "message",
				"text" : "\"Macintosh HD:/Users/taito-otani/Downloads\"",
				"patching_rect" : [ 1301.0, 646.0, 332.0, 20.0 ],
				"outlettype" : [ "" ],
				"id" : "obj-193",
				"numinlets" : 2,
				"numoutlets" : 1
			}

		}
 ],
	"lines" : [ 		{
			"patchline" : 			{
				"source" : [ "obj-215", 0 ],
				"destination" : [ "obj-214", 1 ]
			}

		}
, 		{
			"patchline" : 			{
				"source" : [ "obj-208", 0 ],
				"destination" : [ "obj-220", 0 ],
				"order" : 1
			}

		}
, 		{
			"patchline" : 			{
				"source" : [ "obj-220", 0 ],
				"destination" : [ "obj-215", 0 ]
			}

		}
, 		{
			"patchline" : 			{
				"source" : [ "obj-209", 0 ],
				"destination" : [ "obj-208", 0 ]
			}

		}
, 		{
			"patchline" : 			{
				"source" : [ "obj-204", 0 ],
				"destination" : [ "obj-209", 0 ],
				"order" : 1
			}

		}
, 		{
			"patchline" : 			{
				"source" : [ "obj-208", 0 ],
				"destination" : [ "obj-193", 1 ],
				"order" : 0
			}

		}
, 		{
			"patchline" : 			{
				"source" : [ "obj-205", 0 ],
				"destination" : [ "obj-204", 0 ]
			}

		}
, 		{
			"patchline" : 			{
				"source" : [ "obj-204", 0 ],
				"destination" : [ "obj-18", 0 ],
				"order" : 0
			}

		}
, 		{
			"patchline" : 			{
				"source" : [ "obj-18", 0 ],
				"destination" : [ "obj-208", 0 ]
			}

		}
, 		{
			"patchline" : 			{
				"source" : [ "obj-203", 0 ],
				"destination" : [ "obj-205", 0 ]
			}

		}
 ],
	"appversion" : 	{
		"major" : 8,
		"minor" : 1,
		"revision" : 10,
		"architecture" : "x64",
		"modernui" : 1
	}
,
	"classnamespace" : "box"
}

`````